【问题标题】:Discord.py Not recognising membersDiscord.py 不识别成员
【发布时间】: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


    【解决方案1】:

    将您的 discord.py 更新到最新版本并按照discord.py 官方文档上的本教程进行操作: A Primer to Gateway Intents

    【讨论】:

    • 谢谢,去看看!
    猜你喜欢
    • 2019-01-12
    • 2021-01-21
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 2021-07-09
    • 1970-01-01
    相关资源
    最近更新 更多