Skip to content

Commit ca695a4

Browse files
+ Added base app
1 parent aedd0b3 commit ca695a4

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/app.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
import asyncio
3+
import discord
4+
from discord.ext import commands
5+
6+
from .config import Config
7+
8+
9+
client = commands.Bot(
10+
command_prefix = Config.COMMAND_PREFIX,
11+
intents = discord.Intents.all()
12+
)
13+
14+
# Configuration
15+
@client.event
16+
async def on_ready():
17+
print(f'Client [{client.user}] UP')
18+
19+
@client.event
20+
async def on_message(message: str):
21+
# Allow text to invoke comamnds
22+
await client.process_commands(message)
23+
24+
25+
# Loading cogs
26+
async def load_cogs():
27+
for filename in os.scandir('cogs'):
28+
if filename.name.endswith('.py'):
29+
await client.load_extension(f'cogs.{filename.name[:-3]}')
30+
31+
if __name__ == '__main__':
32+
try:
33+
async def main():
34+
async with client:
35+
await load_cogs()
36+
await client.start(Config.BOT_TOKEN)
37+
38+
asyncio.run(main())
39+
40+
except Exception as e:
41+
raise RuntimeError('Failed to start') from e

0 commit comments

Comments
 (0)