import discord
from discord import app_commands
class aclient(discord.Client):
def __init__(self):
super().__init__(intents=discord.Intents.default())
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild=discord.Object(id=748244591387607111))
self.synced = True
print('---------------------Bot is ready---------------------')
client = aclient()
tree = app_commands.CommandTree(client)
# some slash commands here
# message detection here
client.run('MYTOKEN')
I've already figured out the slash command part, but the message detection doesn't seem to work. In discord.py<2.0.0 I used the following code:
@client.event
async def on_message(message):
# do stuff here
However in discord.py==2.0.0 it doesn't seem to work. I'm not sure if this is a problem related to the version or the fact that I defined the client through a class. Help would be appreciated!