I know that the Python script (3.12) is connecting to the Discord server from the following response in the PyCharm terminal
[2024-08-13 00:55:09] [INFO ] discord.client: logging in using static token
[2024-08-13 00:55:09] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: xxxx).
Logged on as D&D Random Room Generator#9850!
However, when I type “!hello” as a user in the Discord server, nothing happens, aka no “Hello World”. Is there something wrong with my code, or is this some kind of permissions problem with the bot role on the Discord server?
import discord
intents = discord.Intents.default()
intents.message_content = True
class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as {0}!'.format(self.user))
client = MyClient(intents=intents)
async def on_message(self, message):
if message.author == self.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello World!')
client.run('My Token')
2