对于任何有相同问题的人,您可以在下面查看所有评论,但这里是TD;DR:首先,我得到了我想要的频道并将其保存到一个变量中,然后我得到了消息的作者,最后我使用move_编码
async def moveplayer(ctx): channel = bot.get_channel(738705076557709392) member = ctx.message.author await member.move_to(channel)
我真的很喜欢编码,但我不是最好的。最近,我一直在尝试更好地使用python来做一些对我有实际帮助的事情,而不是有趣的基于文本的游戏。我现在要做的是,当使用特定命令时,我希望机器人将用户从一个语音频道移动到另一个语音频道。我一直试图在stackoverflow和互联网的其他地方找到解决方案,但我遇到的一切都不适合我。下面是一些我已经尝试过的东西。我也尝试过使用client = discord.Client()
而不是bot = commands.Bot(command_prefix='hp!')
,但似乎没有任何效果
@bot.command(name='moveme')
@commands.has_role('HpBotAccess')
async def moveplayer(*ctx,**message):
voiceChannel = bot.get_channel(738704912912744450)
await client.move_to(message.author, voiceChannel.id)
@bot.command(name='moveme')
@commands.has_role('HpBotAccess')
async def moveplayer(message):
channel = discord.utils.find(lambda x: x.name == 'Vibin 3', message.server.channels)
await client.move_member(message.author, channel)
@bot.command(name='moveme')
@commands.has_role('HpBotAccess')
async def moveplayer(message):
await move_to(716193638433947690)
我也尝试过阅读这些文档,但我并不真正理解它们,因此上面的内容正是我在其他帖子/一小部分文档中尝试过的。如果你有一个解决方案或可以帮助我,请张贴它!谢谢大家!
另外,我意识到这个问题以前已经发布过了,但是其他帖子上的解决方案对我不起作用
我有一个在discord.py机器人上执行类似操作的函数。我想你的问题是你需要打电话给
member.move_to(channel)
。例如,我的机器人执行以下操作您需要在
member
类上使用move_to
,它将channel
作为参数。您需要使用client
来提取要操作的相关数据相关问题 更多 >
编程相关推荐