-1

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.

1 Answers1

0

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

Infinity
  • 161
  • 1
  • 8
  • Hey, Guess its now giving me error..:here is the traceback: `main.py:1132: RuntimeWarning: coroutine 'Guild.vanity_invite' was never awaited vanity = (await ctx.guild.vanity_invite().url) RuntimeWarning: Enable tracemalloc to get the object allocation traceback` Help me out please. – Iqbal Hossain Jul 07 '22 at 03:04
  • ok sorry I put a bracket in the wrong place - code should be working now :) – Infinity Jul 13 '22 at 19:04
  • Yo, Really appreciate your help man! It worked – Iqbal Hossain Jul 14 '22 at 11:51