zakerytclarke commited on
Commit
fbb941f
·
verified ·
1 Parent(s): 7b1d98b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import discord
2
+ import os
3
+
4
+ DISCORD_TOKEN = os.environ.get("discord_token")
5
+
6
+ # Create an instance of Intents and enable the required ones
7
+ intents = discord.Intents.default() # Default intents enable basic functionality
8
+ intents.messages = True # Enable message-related events
9
+
10
+ # Create an instance of a client with the intents
11
+ client = discord.Client(intents=intents)
12
+
13
+ # Event when the bot has connected to the server
14
+ @client.event
15
+ async def on_ready():
16
+ print(f'Logged in as {client.user}')
17
+
18
+ # Event when a message is received
19
+ @client.event
20
+ async def on_message(message):
21
+ # Check if the message is from the bot itself to prevent a loop
22
+ if message.author == client.user:
23
+ return
24
+
25
+ # Respond with "pong" if the message contains "ping"
26
+ if 'ping' in message.content.lower():
27
+ await message.channel.send('pong')
28
+
29
+ # Run the bot with your token
30
+
31
+ client.run(DISCORD_TOKEN)
32
+