File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments