PY-Cord Bot上网,但没有回应

发布于 2025-02-03 16:01:57 字数 294 浏览 5 评论 0 原文

我一直在尝试制作一个Discord机器人,但是当我将此代码放置时,机器人在线上转动,但是如果我使用命令,则没有该机器人的响应。

我从他们的github表示

from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.command()
async def test(ctx):
    await ctx.send(content="Test")
    
bot.run('token')

感谢。

I have been trying to make a discord bot but when I put this piece of code tougether the bot turned online but if I use the command there is no response from the bot.

I used the import command from their github

from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.command()
async def test(ctx):
    await ctx.send(content="Test")
    
bot.run('token')

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我爱人 2025-02-10 16:01:57

使用最新的pycord版本(如果我没记错的话,从2.0.0b5开始),他们使用不满的网关版本足够高,您必须启用(特权)消息内容意图在您的应用程序的开发人员网站上都/bot ,但您也可以转到< https://discord.com/developers/developers/applications 然后导航到您的机器人页面)

在您的代码中:

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

使用此设置,您的机器人将接收带有内容的消息事件,并可以实际处理您的命令,


请注意,一旦您的机器人达到100台服务器,此意图将要求您通过Discord进行白色列出过程。在此之前,您可以自由实现意图测试和构建机器人

With the latest Pycord versions (starting from 2.0.0b5 if I recall correctly), they use a Discord gateway version high enough that you have to enable the (privileged) message content intent both on your application's developer site (https://discord.com/developers/applications/YOUR_APPLICATION_ID/bot, but you can also go to https://discord.com/developers/applications and then navigate to your bot page from there)
message content intent on the Discord dev page
and in your code:

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

With this setup, your bot will receive message events with the content and can actually process your commands


Note that once your bot reaches 100 servers, this intent will require you to undergo a whitelisting process by Discord. Until then, you can freely enable the intent to test and build your bot

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文