discord.py - 将用户移动到不同的 VC discord.py
问题描述
我创建了一个执行各种功能的不和谐机器人。我希望它能够移动用户。但是,访问官方 discordpy 网站并尝试阅读文档并没有帮助。我已经查看了此处提供的答案,但仍然没有解决方案。
到目前为止,我试过这个:
await client.move_member(id, channel)
await member.move_to(channel)
解决方案
获得所有必需的不和谐模型以使命令正常工作很重要。如果您使用命令扩展,此命令将任意数量的成员移动到另一个语音通道:
import discord
from discord.ext import commands
@bot.command()
async def move(ctx, members:commands.Greedy[discord.Member], *, channel:discord.VoiceChannel):
for member in members:
await member.move_to(channel=channel)
示例用法:move @Someone @SomeoneElse VoiceChannelA
遗憾的是,# 不能指定语音通道,因此您必须准确输入名称。此commands.Greedy
方法也存在一些问题,因此您可能希望改进此命令或添加良好的错误处理:https ://discordpy.readthedocs.io/en/latest/ext/commands/commands.html#greedy
推荐阅读
- java - Spring Securities 测试找不到 Bean 错误
- python - 如何在 ffmpeg-python 中使用“最短”参数
- html - 在 R Shiny 中设置相对链接/锚点
- python - 如何在 Atoti 中动态过滤向量?
- json - 使用 Google 表格作为 JSON 端点的 Google 表格发布到 Web 问题
- python - 如何使方法 JSON 可序列化以在自定义 Pyspark 转换器中使用
- angular - 一个 svg 图片文件在 Palette 中渲染成功,但在 Angular 和 GoJS 中却没有
- mysql - 存储过程中查询不使用主索引,速度很慢
- c# - 如何更改 netstandard 2.0 库使用的 Newtonsoft.Json 的版本
- wmi - 设计电压参数是什么意思