【发布时间】:2020-09-06 02:26:01
【问题描述】:
我有一个机器人,只有当调用它的用户在同一个语音通道中时,我才想收听命令。这是我的代码。
@bot.command(name='leave', help='Disconnects the bot.')
async def leave(ctx):
user_channel = ctx.message.author.voice.channel
bot_channel = ctx.guild.voice_client
print(user_channel)
print(bot_channel)
if user_channel == bot_channel:
client = ctx.guild.voice_client
await client.disconnect()
else:
await ctx.send('You have to be connected to the same voice channel to disconnect me.')
但是,我的问题是这些打印行返回不同的字符串。用户频道:vc 2,机器人频道: 我怎样才能让它们都读取语音通道的 ID,以便我可以比较它们?
【问题讨论】:
标签: python discord discord.py discord.py-rewrite