python检测到虚荣url discord.py

发布于 2025-02-13 08:50:04 字数 276 浏览 0 评论 0原文

我在机器人上制作了ServerInfo命令。因此,我要添加服务器信息命令也显示公会的虚荣心!但是我阅读了整个不和谐文档,但找不到如何使机器人检测虚荣URL并发送。然后,我尝试通过将该命令作为单个命令进行测试。这是我的代码:

@bot.command()
async def vanity(ctx):
  vanity = str(ctx.guild.vanity_url)
  await ctx.send(vanity)

机器人对代码没有响应。帮助您将不胜感激。提前致谢。

I am making a Serverinfo command on my bot. So i want add the server info command show the guild's vanity too! But I read the whole discord documentation but can't find how can i make the bot detect the vanity url and sends it. Then I tried to test by making that command as a single command. Here is my code:

@bot.command()
async def vanity(ctx):
  vanity = str(ctx.guild.vanity_url)
  await ctx.send(vanity)

The bot doesn't response with the code. A help will be appreciated. Thanks in advance.

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

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

发布评论

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

评论(1

晌融 2025-02-20 08:50:04

尝试此尝试获取虚荣url:

vanity = (await ctx.guild.vanity_invite()).url

文档参考: https://discordpy.readthedocs.io/en/stable/api.html#discord.guild.guild.vanity_invite

Try this to get the vanity url:

vanity = (await ctx.guild.vanity_invite()).url

Documentation reference: https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild.vanity_invite

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