discord.py将人们移动到不同的语音频道 channel_a=bot.get_频道(78074342260993) @bot.command() 异步def移动(ctx): i=0 而我(参与者): 如果类型(参与者[i])!=str: 等待参与者[i]。移动到(频道a) i+=1

discord.py将人们移动到不同的语音频道 channel_a=bot.get_频道(78074342260993) @bot.command() 异步def移动(ctx): i=0 而我(参与者): 如果类型(参与者[i])!=str: 等待参与者[i]。移动到(频道a) i+=1,discord.py,Discord.py,我想把人们转移到另一个语音聊天室 但是使用这个代码,人们就可以与语音聊天室断开连接 我已经检查了频道ID是否正确 如果你知道解决办法,如果你能告诉我,我将不胜感激 channel_a = bot.get_channel(780743421442260993) @bot.command() async def Movee(ctx): i = 0 while i < len(participant): if type(participant[i]) != st

我想把人们转移到另一个语音聊天室

但是使用这个代码,人们就可以与语音聊天室断开连接

我已经检查了频道ID是否正确

如果你知道解决办法,如果你能告诉我,我将不胜感激

channel_a = bot.get_channel(780743421442260993)

@bot.command()
async def Movee(ctx):
    i = 0
    while i < len(participant):
        if type(participant[i]) != str:
            await participant[i].move_to(channel_a)
        i += 1

@bot.command()
异步def设置(ctx):
通道[0]=bot.get\u通道(ctx.message.author.voice.channel.id)
等待ctx发送(“完成”)
@bot.command()
异步def移动(ctx):
i=0
而我(参与者):
如果类型(参与者[i])!=str:
等待参与者[i]。移动到(频道[0])
i+=1
如上所述,它工作得非常好

我认为这是由异步函数的工作方式造成的

如果不使用
list
,它可能会很好地工作

我把它贴在和我有同样问题的人身上


我也欢迎任何知道更好方法的人:D

有什么原因使代码过于复杂吗?你可以写两行。这个代码中有很多错误,您在哪里定义了参与者?还有-为什么要在命令之外定义频道?你确定频道id是语音频道id吗?整个代码太长了,所以我只带了一些。另外,频道id似乎不是固定的,因此我还创建了另一个指定频道id的命令,因此我在命令之外定义了频道id:)channel\u a=bot.get\u channel(ctx.message.author.voice.channel.id)接收通道ID以供参考的代码。是否有理由使用带递增整数的
while
-循环而不是
for
for each
循环?
channel = []
@bot.event
async def on_ready():
    channel_a = bot.get_channel(780743421442260993)   
    channel.append(channel_a)
@bot.command()
async def setChA(ctx):
    channel[0] = bot.get_channel(ctx.message.author.voice.channel.id)
    await ctx.send("Done")

@bot.command()
async def Move(ctx):
    i = 0
    while i < len(participant):
        if type(participant[i]) != str:
            await participant[i].move_to(channel[0])
        i += 1