如何从discord.py中获取reddit的client_id,client_secret和user_agent参数
我正在创建一个discord.py bot,我想做的就是添加!meme
命令,从r/memes subreddit中汲取随机模因。关于如何做到这一点,我在堆栈溢出上找到了一些代码。我的问题是我需要3个参数,client_id
,client_secret
和user_agent
,我不知道该如何获取。这是我发现的代码:
reddit = praw.Reddit(client_id='CLIENT_ID HERE',
client_secret='CLIENT_SECRET HERE',
user_agent='USER_AGENT HERE')
@bot.command()
async def meme():
memes_submissions = reddit.subreddit('memes').hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
await bot.say(submission.url)
有人可以帮助我获得这些参数吗?
I'm creating a Discord.py bot and what I want it to do is add a !meme
command on which it pulls a random meme from the r/memes subreddit. I have found some code on Stack Overflow as to how to do that. My problem is that I need 3 parameters, client_id
, client_secret
and user_agent
, which I don't know how to get. Here's the code I found:
reddit = praw.Reddit(client_id='CLIENT_ID HERE',
client_secret='CLIENT_SECRET HERE',
user_agent='USER_AGENT HERE')
@bot.command()
async def meme():
memes_submissions = reddit.subreddit('memes').hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = next(x for x in memes_submissions if not x.stickied)
await bot.say(submission.url)
Can someone help me get those parameters?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论