问题描述
我想在用户执行命令时更改状态。 我在自己的班级中有 discord 机器人。要改变存在,我需要 self 参数。 但是当我写
@bot.command()
async def change(self,ctx):
await self.client.change_presence(activity=discord.Game("P-Hub"))
我收到错误:
discord.ext.commands.errors.MissingrequiredArgument: ctx is a required argument that is missing.
当我写:
@bot.command()
async def change(ctx,self):
await self.client.change_presence(activity=discord.Game("P-Hub"))
我收到此错误:
discord.ext.commands.errors.MissingrequiredArgument: self is a required argument that is missing.
整个代码是:
class discordBot():
def __init__(self,client,token):
self.client = client
self.token = token
def run(self):
self.client.run(self.token)
@bot.command()
async def change(ctx,self):
await self.client.change_presence(activity=discord.Game("P-Hub"))
@bot.event
async def on_ready():
print("My Ready is Body")
@bot.listen()
async def on_message(message):
print(str(message.author) + ": " + message.content)
if __name__ == '__main__':
client = discordBot(bot,'token')
client.run()
有人有解决办法吗?