【发布时间】:2020-09-22 16:24:44
【问题描述】:
我正在尝试向我的机器人添加 .reddit 命令。这是我的代码:
@client.command(name="random", aliases=["reddit"])
async def _random(ctx, subreddit: str = ""):
reddit = None
if reddit_app_id and reddit_app_secret:
reddit = praw.Reddit(client_id=reddit_app_id,client_secret=reddit_app_secret,user_agent="MASTERBOT:%s1.0" % reddit_app_id)
if reddit:
submissions = reddit.subreddit(subreddit).hot()
submission = next(x for x in submissions if not x.stickied)
await ctx.send(submissions.url)
我已导入所有内容,在出现此错误之前一切似乎都很好:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'randint'
据我了解,该程序不知道 randint 是什么。我检查了我是否打错了,但没有。一切似乎都很好。我在同一命令上遇到了另一个错误,但我设法修复了它。但是这个得到了我,我需要你的帮助。
这些是新的错误:
AttributeError: 'coroutine' object has no attribute 'url'
。
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
【问题讨论】:
标签: python discord.py