I’m doing a little experiment trying to see if I can generate invite from server my bot has been added to. I encounter a problem in the definition of something called InviteTarget that I am not even using (?)
The code is the following:
@commands.hybrid_command(name='makeinvite', with_app_command=True)
@commands.has_permissions(administrator=True)
async def makeinvite(self, ctx, channel: discord.abc.GuildChannel = None):
"""
Generates an invitation link for any server the bot is in.
Parameters:
channel: The ID of channel you want to generate an invitation for. If not provided, it will use the current channel where command was used.
"""
if channel is None:
invite = await ctx.channel.create_invite(max_uses=1,unique=True)
else:
invite = await channel.create_invite(max_uses=1, unique=True)
I then get the error message CommandInvokeError: Command 'makeinvite' raised an exception: NameError: name 'InviteTarget' is not defined
I have found several posts that either points at invite link from the current ctx.channel
or with non working solutions.