问题
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")
This is my code but I when I try to move the user it gives me the error "The channel provided must be a voice channel."
I know the bot works because I had some simple commands earlier that would reply to messages earlier and they worked fine.
I am new to python and discord bots so I don't really know what to do. Any help is appreciated.
回答1:
The channel argument to move_member must be a Channel object, not just the channel id. This is noted in the documentation for move_member
You cannot pass in a Object instead of a Channel object in this function.
@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")
来源:https://stackoverflow.com/questions/48847080/the-channel-provided-must-be-a-voice-channel-error-with-move-member