首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动将某个用户移动到不同的语音聊天的Discord.py机器人

自动将某个用户移动到不同的语音聊天的Discord.py机器人
EN

Stack Overflow用户
提问于 2021-11-24 09:42:25
回答 1查看 64关注 0票数 0

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

EN

回答 1

Stack Overflow用户

发布于 2021-11-24 14:23:13

你可以的。只需使用on_voice_state_update事件和move_to函数即可。例如:

代码语言:javascript
复制
@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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70093804

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档