首页 > 解决方案 > 将用户移动到不同的 VC discord.py

问题描述

我创建了一个执行各种功能的不和谐机器人。我希望它能够移动用户。但是,访问官方 discordpy 网站并尝试阅读文档并没有帮助。我已经查看了此处提供的答案,但仍然没有解决方案。

到目前为止,我试过这个:

await client.move_member(id, channel)
await member.move_to(channel)

标签: discord.py

解决方案


获得所有必需的不和谐模型以使命令正常工作很重要。如果您使用命令扩展,此命令将任意数量的成员移动到另一个语音通道:

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


推荐阅读