好的,所以我知道执行此操作的命令,但我的问题是我不知道要传递给参数的参数.我希望我的代码获取用户的消息内容,然后将用户移动到名为afk"的语音频道.这是我的代码片段:
Okay, so I know the command to do this but my issue is I do not know what arguments to pass to the parameters. I want my code to take a user's message content and then move the user to a voice channel named "afk". Here is a snippet of my code:
我要做的就是将输入单词 !move 的用户移动到另一个语音频道.如果我的代码不好,我很抱歉,但我只是需要这个.
All I want to do is move a user that types the words !move in any case to be moved to another voice channel. I am sorry if my code is bad but I just need this down.
我知道您可能需要查看我的定义,但仅此而已:
I know you might need to see my definitions but all it is:
def on_message(message):
if '!MOVE' in message.content.upper():
author = message.author
voice_channel = id('afk')
await client.move_member(author, voice_channel)
client.move_member 有两个参数:一个 Member 和一个 Channel.我们可以使用 discord.utils.find 从服务器频道列表中获取频道.
client.move_member takes two arguments: a Member and a Channel. We can use discord.utils.find to get the channel from the servers list of channels.
channel = discord.utils.find(lambda x: x.name == 'afk', message.server.channels)
await client.move_member(message.author, channel)
一些进一步的说明:
Server.afk_channel 属性.discord.ext.commands 扩展来实现您的命令,以防止您的 on_message 变得混乱.Server.afk_channel attribute. discord.ext.commands extension to implement your commands, to keep your on_message from getting cluttered.这篇关于如何使用 discord.py API 将用户移动到 discord 上的特定频道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
python:不同包下同名的两个模块和类python: Two modules and classes with the same name under different packages(python:不同包下同名的两个模块和类)
配置 Python 以使用站点包的其他位置Configuring Python to use additional locations for site-packages(配置 Python 以使用站点包的其他位置)
如何在不重复导入顶级名称的情况下构造python包How to structure python packages without repeating top level name for import(如何在不重复导入顶级名称的情况下构造python包)
在 OpenShift 上安装 python 包Install python packages on OpenShift(在 OpenShift 上安装 python 包)
如何刷新 sys.path?How to refresh sys.path?(如何刷新 sys.path?)
分发带有已编译动态共享库的 Python 包Distribute a Python package with a compiled dynamic shared library(分发带有已编译动态共享库的 Python 包)