【发布时间】:2018-02-14 06:28:31
【问题描述】:
我在将move_member() 用于 python 机器人时遇到问题。该命令的目的是通过将用户移动到频道来“踢”用户,然后将其删除,以便他们断开语音呼叫,但不需要返回服务器的邀请。我知道仅移动用户即可实现此目的,但我希望用户断开连接。
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')
该行给出了错误:
提供的频道必须是语音频道
await bot.move_member(victim,"kick")
这一行给出了这个错误:
'str' 对象没有属性 'id'
await bot.delete_channel("kick")
我很确定您必须获取频道 ID 而不是“踢”,但我不知道该怎么做,因为下面的代码不起作用,即使我替换
ChannelType.voice 到 discord.ChannelType.voice
discord.utils.get(server.channels, name='kick', type=ChannelType.voice)
【问题讨论】:
-
只是为了在同一页面上,如果用户还没有语音,您不能将成员移动到语音聊天聊天。 Discord 只是不支持。
-
看起来 OP 想要进行语音聊天,而不是真正的踢。如果是这样,下一个明显的事情就是 OP 不会踢不在语音聊天中的人。