如何从discord.py中获取reddit的client_id,client_secret和user_agent参数

发布于 2025-01-29 04:25:17 字数 741 浏览 3 评论 0原文

我正在创建一个discord.py bot,我想做的就是添加!meme命令,从r/memes subreddit中汲取随机模因。关于如何做到这一点,我在堆栈溢出上找到了一些代码。我的问题是我需要3个参数,client_idclient_secretuser_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文