我在使用move_member()
来处理python机器人时遇到了麻烦。该命令的目的是通过将用户移动到某个频道来“踢”用户,然后将其删除,以便与语音呼叫断开连接,但不需要邀请回服务器。我知道,仅仅移动用户即可达到此目的,但我希望用户能够断开连接。Discord.py与move_member()的问题
import discord
import random
import time
import asyncio
from discord.ext import commands
from discord.ext.commands import Bot
bot = commands.Bot(command_prefix="!")
@bot.event
async def on_ready():
await bot.change_presence(game=discord.Game(name='with fire'))
print("Logged in as " + bot.user.name)
print(discord.Server.name)
@bot.command(pass_context=True)
async def kick(ctx,victim):
await bot.create_channel(message.server, "kick", type=discord.ChannelType.voice)
await bot.move_member(victim,"kick")
await bot.delete_channel("bad boi")
bot.run('TOKEN_ID')
行给出了错误:
The channel provided must be a voice channel
await bot.move_member(victim,"kick")
和此行给出了这样的错误:
'str' object has no attribute 'id'
await bot.delete_channel("kick")
Im相当肯定,你必须获得信道ID而不是“踢”,但我不明白如何去做,因为c下面颂心不是工作,甚至当我更换 ChannelType.voice
到discord.ChannelType.voice
discord.utils.get(server.channels, name='kick', type=ChannelType.voice)
只要在同一页面上,如果用户尚未进行语音聊天,则您不能***成员移动到语音聊天。不和谐的dosnt支持。 – abccd
看起来好像OP想要进行语音聊天踢球而不是实际踢球。如果是这样,这将是下一个显而易见的事情,OP不会踢人不在语音聊天中的人。 – xNinjaKittyx