There was a need to get the name of the server from the line with the invitation link, where this invitation actually leads. I get this line from the form. I use the disnake library (fork discord.py , therefore, I indicated it, because there are probably no differences in this regard). How can I actually do this and can I do it at all?
Asked
Active
Viewed 72 times
0
-
Does this answer your question? [Discord.py get server name or id by server link](https://stackoverflow.com/questions/70773324/discord-py-get-server-name-or-id-by-server-link) – TheFungusAmongUs Sep 18 '22 at 21:24
1 Answers
0
You can just use the guild
property of an Invite to access the Guild and then get the Name from there.
Example:
invite = await bot.fetch_invite("discord.gg/example_invite")
print(invite.guild.name)
This was tested in discord.py but it should be the same in disnake.
Documentation: https://docs.disnake.dev/en/stable/api.html?highlight=invite#disnake.Invite

moinierer3000
- 1,927
- 2
- 9
- 24