discord.py-重写音乐 - 无法使用检查

discord.py-rewrite music - Cannot use check

所以,我有一个 Discord BOT,其音乐齿轮看起来像这样:

def setup(bot):

    class Music:

        __slots__ = ("players", )

        def __init__(self):
            self.players = {}

        def get_player(self, ctx):
            # Retrieve the guild player.

        def check_player(self):

            def predicate(ctx):
                # PREVIOUS CHECK
                player = self.get_player(ctx)
                # CHECK PLAYER STATE

            return commands.check(predicate)

        @commands.command()
        @check_player(self)
        async def a_command(self, ctx):
            pass

    bot.add_cog(Music())

但是我无法在 a_command() 命令上使用 check_player() 检查,因为 self 未定义。有人知道我该如何解决这个问题吗?

@PatrickHaugh

def get_player(self, ctx):
    """Retrieve the guild player, or generate one."""
    try:
        player = self.players[ctx.guild.id]
    except KeyError:
        player = MusicPlayer(ctx, bot)
        self.players[ctx.guild.id] = player
    except:
        return None

    return player

这就是 get_player() 检查的工作原理。