尝试对我的列表执行任何操作时"AttributeError: 'music' object has no attribute 'music_queue'"收到此错误


class music(commands.Cog):
def init(self, client):
self.client = client
self.music_queue = []
cog_ext.cog_slash(name='play', description='play music')
async def play(self,ctx,song):
self.music_queue.append(song)
print(self.music_queue)
AttributeError: 'music' object has no attribute 'music_queue'

首先,这不是一个与不和谐.py相关的问题,因为它不支持斜杠命令。其次,它应该是@cog_ext.cog_slash(name='play', description='play music')。第三,缩进使装饰器(以及命令(不会成为类的一部分。

class Music(commands.Cog):
def __init__(self, client):
self.client=client
self.music_queue=[]
@cog_ext.cog_slash(
name="play",
description="plays a song (probably)"
)
async def play(self, ctx, song):
self.music_queue.append(song)
return

最新更新