Reddit 不可调用 PRAW Discord.Py
Reddit is not callable PRAW Discord.Py
当我尝试 运行 从 reddit 收集模因的脚本时,我收到此错误:
Traceback (most recent call last):
File "C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Reddit' object is not callable
我触发 .reddit
命令的代码是这样的:
@client.command(description="This command is not working right now")
async def reddit(self,ctx,subreddit: str =""):
self.reddit = praw.Reddit(client_id=reddit_app_id,
client_secret=reddit_app_secret,user_agent="MASTERBOT:½s:1.0")
if self.reddit():
chosen_subreddit = reddit_enabled_meme_subreddits[0]
if subreddit:
if subreddit in reddit_enabled_meme_subreddits:
chosen_subreddit = subreddit
submissions = self.reddit.subreddits(chosen_subreddit).hot()
post_to_pick = random.randint(1,10)
for i in range(0, post_to_pick):
submissions = next(x for x in submissions if not x.stickied)
await ctx.send(submissions.url)
else:
await ctx.send("This is not working")
这些是我的 ID、秘密和 subreddits:
reddit_enabled_meme_subreddits = ["memes","dankmemes"]
reddit_app_secret = "SECRET"
reddit_app_id = "ID"
我把所有东西都导入了,当我看别人的时候一切似乎都很好,但我的就是不行!
我认为您的问题在于:
if self.reddit():
您正在尝试调用 praw.Reddit()
返回的内容。
也许尝试删除括号。
当我尝试 运行 从 reddit 收集模因的脚本时,我收到此错误:
Traceback (most recent call last):
File "C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'Reddit' object is not callable
我触发 .reddit
命令的代码是这样的:
@client.command(description="This command is not working right now")
async def reddit(self,ctx,subreddit: str =""):
self.reddit = praw.Reddit(client_id=reddit_app_id,
client_secret=reddit_app_secret,user_agent="MASTERBOT:½s:1.0")
if self.reddit():
chosen_subreddit = reddit_enabled_meme_subreddits[0]
if subreddit:
if subreddit in reddit_enabled_meme_subreddits:
chosen_subreddit = subreddit
submissions = self.reddit.subreddits(chosen_subreddit).hot()
post_to_pick = random.randint(1,10)
for i in range(0, post_to_pick):
submissions = next(x for x in submissions if not x.stickied)
await ctx.send(submissions.url)
else:
await ctx.send("This is not working")
这些是我的 ID、秘密和 subreddits:
reddit_enabled_meme_subreddits = ["memes","dankmemes"]
reddit_app_secret = "SECRET"
reddit_app_id = "ID"
我把所有东西都导入了,当我看别人的时候一切似乎都很好,但我的就是不行!
我认为您的问题在于:
if self.reddit():
您正在尝试调用 praw.Reddit()
返回的内容。
也许尝试删除括号。