“非类型”对象没有属性“节点”链接

2024-06-16 17:51:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试用python制作一个音乐机器人,但出现以下错误:

AttributeError: 'NoneType' object has no attribute 'node'

我怀疑这部分代码导致了此问题:

    @cog_ext.cog_slash(name="play", guild_ids=guild_ids, description="Play song")
    async def play(self, ctx, *, query: str):
        """ Searches and plays a song from a given query. """
        # Get the player for this guild from cache.
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)
        # Remove leading and trailing <>. <> may be used to suppress embedding links in Discord.
        query = query.strip('<>')

        # Check if the user input might be a URL. If it isn't, we can Lavalink do a YouTube search for it instead.
        # SoundCloud searching is possible by prefixing "scsearch:" instead.
        if not url_rx.match(query):
            query = f'ytsearch:{query}'

        # Get the results for the query from Lavalink.
        results = await player.node.get_tracks(query)

        # Results could be None if Lavalink returns an invalid response (non-JSON/non-200 (OK)).
        # ALternatively, resullts['tracks'] could be an empty array if the query yielded no tracks.
        if not results or not results['tracks']:
            return await ctx.send('Nothing found!')

让我知道如果有人需要更多的代码,我不想垃圾邮件所有的代码,如果它是不需要的


Tags: theno代码fromforifnotbe