我需要一个机器人的帮助我尝试了很多东西并尝试了其他人的代码,但我没有做对。当有人加入语音频道集线器时,我需要制作一个机器人,它将创建一个语音和文本频道,并分配一个音乐机器人:音乐 1、音乐 2 等。离开语音频道后,它将删除语音和文本渠道。并且通过做!invite @name
然后他或她可以做!accept
。但是由于我是 Python 的新手,我无法自己创建它,所以我真的很希望有人可以帮助我,以便我可以学习。到目前为止,我得到了这个。
@commands.has_role('auth')
async def create_channel(ctx, channel_name='new channel'):
guild = ctx.guild
existing_channel = discord.utils.get(guild.channels, name=channel_name)
if not existing_channel:
print(f'Creating a new channel: {channel_name}')
await guild.create_text_channel(channel_name)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.errors.CheckFailure):
await ctx.send('You do not have the correct role for this command.')
问候Sem