【问题标题】:The channel provided must be a voice channel. error with move_member提供的频道必须是语音频道。 move_member 错误
【发布时间】:2018-07-28 13:28:36
【问题描述】:
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
import time

bot = commands.Bot(command_prefix='$')

@bot.event
async def on_ready():
print ("Ready")

@bot.command(pass_context=True)
async def Move(ctx):
    #channel to move to '414543063575429131'
    #user to move '192361974053470208'
    await bot.move_member('192361974053470208', '414543063575429131')
    print("done")


bot.run("token_here")

这是我的代码,但是当我尝试移动用户时,它给了我错误“提供的频道必须是语音频道”。

我知道机器人可以正常工作,因为我之前有一些简单的命令可以更早地回复消息并且它们运行良好。

我是 python 和不和谐机器人的新手,所以我真的不知道该怎么做。任何帮助表示赞赏。

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    move_member 的频道参数必须是 Channel 对象,而不仅仅是频道 ID。这在documentation for move_member

    中有说明

    您不能在此函数中传入Object 而不是Channel 对象。

    @bot.command(pass_context=True)
    async def move(ctx):
        destination = '414543063575429131'
        user = '192361974053470208'
        await bot.move_member(ctx.message.server.get_member(user), bot.get_channel(destination)) 
        # The get_member doesn't look to be strictly necessary, but it doesn't hurt
        # and improves readability
        print("done")
    

    【讨论】:

      猜你喜欢
      • 2021-04-13
      • 2019-05-24
      • 2019-11-24
      • 2020-07-07
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      • 2018-04-04
      • 1970-01-01
      相关资源
      最近更新 更多