当我离开频道discord.py时,我如何删除频道室


@bot.event
async def on_voice_state_update(member, before, after):
if before.channel is None and after.channel is not None:
await member.guild.system_channel.send(
"{} into the voice room".format(member.nick)
)
channel = await member.guild.create_text_channel('123')
if before.channel is not None and after.channel is None:
await member.guild.system_channel.send(
"{} out of the voice room".format(member.nick)
)
channel = await member.guild.delete_text_channel('123')

当我进入语音频道时,机器人会制作一个文本频道如果我离开了语音频道,机器人应该删除文本通道

但当我外出时,机器人不会删除频道如何修复此代码?

.delete_text_channel((无效,必须使用.delete((代替

channel = discord.utils.get(member.guild.channels, name="123")
# If channel doesn't exits or channel is not TextChannel
if type(channel) != discord.channel.TextChannel or channel is None: 
print("No channel found!")
return
await channel.delete()

最新更新