I want to change the presence when a user executes a command. I have the Discord bot in an own Class. To change the presence I need the self argument. But when I write
@bot.command()
async def change(self, ctx):
await self.client.change_presence(activity=discord.Game("P-Hub"))
I get the Error:
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
And when I write:
@bot.command()
async def change(ctx, self):
await self.client.change_presence(activity=discord.Game("P-Hub"))
I get this error:
discord.ext.commands.errors.MissingRequiredArgument: self is a required argument that is missing.
The whole code is:
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()
Does anyone have a solution?