【问题标题】:Discord.py bot to move a certain user to a different voice chat automaticallyDiscord.py 机器人自动将某个用户移动到不同的语音聊天
【发布时间】:2021-11-24 22:33:22
【问题描述】:

我目前正在使用 discord.py 库编写一个机器人。 机器人(脚本)有什么方法可以自动将用户移动到不同的语音频道? 例如,您键入命令让用户 X 自动移动到特定的语音聊天,并且每次用户 X 加入语音频道时,他都会被移动。

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    你可以做到。只需使用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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-02
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      • 2021-05-24
      • 1970-01-01
      相关资源
      最近更新 更多