我目前正在使用discord.py库编写一个机器人。有没有办法让机器人(脚本)自动将用户移动到不同的语音通道?例如,您为用户X键入命令以自动移动到特定的语音聊天,每次用户X加入语音通道时,他都会被移动。
发布于 2021-11-24 14:23:13
你可以的。只需使用on_voice_state_update事件和move_to函数即可。例如:
@commands.Cog.listener() # for cogs. If you haven't implemented cogs use `@client.event`
async def on_voice_state_update(self, member, before, after): # also remove `self` argument if you haven't implemented cogs
if after.channel is not None: # check if member join to new voice channel
channel = something # you can specify voice channel here. For example use `self.client.get_channel(id)` to get channel by ID
await member.move_to(channel)https://stackoverflow.com/questions/70093804
复制相似问题