【发布时间】:2021-02-20 05:31:17
【问题描述】:
我的 Discord 机器人在启动后已切换到至少 1 个其他语音频道之前无法识别语音频道中的成员(加入频道后,用户必须手动切换到其他频道,然后返回,让机器人识别成员并能够将他们移动到所需的频道)。这有点违反直觉,违背了我的机器人的目的。
from discord.ext import commands
class Mute(commands.Cog):
# Commands
@commands.command()
async def mute(self, ctx):
vc = ctx.author.voice.channel
for member in vc.members:
await member.edit(mute=True)
await ctx.channel.purge()
@commands.command()
async def unmute(self, ctx):
vc = ctx.author.voice.channel
for member in vc.members:
await member.edit(mute=False)
await ctx.channel.purge()
@commands.command()
async def start(self, ctx):
vc = ctx.author.voice.channel
await ctx.channel.send("A new game has started!")
await ctx.channel.send("Users will now be moved. Game has started!")
await ctx.channel.purge()
channel = discord.utils.get(ctx.guild.channels, name="AU voice")
for member in vc.members:
await member.move_to(channel)
def setup(client):
client.add_cog(Mute(client))
【问题讨论】:
标签: python discord.py