-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
42 lines (32 loc) · 974 Bytes
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import discord
from discord.ext import commands
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Hello, World!"
if __name__ == '__main__':
app.run(port=4000)
# Retrieve the token from environment variable
TOKEN = os.environ.get('TOKEN')
if not TOKEN:
raise ValueError("The TOKEN environment variable is not set!")
# Intents configuration
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
# Simple load_extension
async def load_extensions():
try:
await bot.load_extension("bot.commands.ping")
await bot.load_extension("bot.commands.grid")
print("Extensions successfully loaded.")
except Exception as err:
print(f"Failed to load an extension: {err}")
@bot.event
async def on_ready():
print(f"{bot.user.name} is now online!")
await load_extensions()
bot.run(TOKEN)