如何修复 discord.ext.command.errors.CommandInvokeError: 命令引发异常: 属性错误: 'int' 对象没有属性 'id'



使用python创建一个机器人,将用户从一个语音通道移动到另一个语音通道

@client.command(pass_context = True)
async def asw(ctx, member: discord.Member):
channels = 1062106353230950430
await member.move_to(channel=channels)

discord.Member.move_to中参数通道需要通道对象而不是id。您可以使用discord.Guild.get_channel获取它。

代码将是:

@client.command(pass_context = True)
async def asw(ctx, member: discord.Member):
channels = ctx.guild.get_channel(1062106353230950430)
await member.move_to(channel=channels)

最新更新