-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (49 loc) · 1.69 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
### Meji Discord Bot ###
### Imports ###
# General
import traceback
import os
# Library
from nextcord.ext import commands
# Internal
import utils.apis as apis
# Define the client and how to reference it.
client = commands.Bot(command_prefix=commands.when_mentioned)
# Define some utility commands for shutdown and cogs.
@client.command()
@commands.has_role('MesiTeam')
async def shutdown(ctx: commands.Context):
await ctx.message.delete()
exit()
@client.command()
async def load(ctx: commands.Context, extension: str):
client.load_extension(f'cogs.{extension}')
print(f'{extension} successfully loaded')
@client.command()
async def unload(ctx: commands.Context, extension: str):
client.unload_extension(f'cogs.{extension}')
print(f'{extension} successfully unloaded')
@client.command()
async def reload(ctx: commands.Context, extension: str):
client.unload_extension(f'cogs.{extension}')
client.load_extension(f'cogs.{extension}')
print(f'{extension} successfully re-loaded')
await ctx.message.delete()
# for loop to find cogs folder
for filename in os.listdir('./cogs'):
if filename.endswith('.py') and '_' not in filename:
try:
client.load_extension(f'cogs.{filename[:-3]}')
except BaseException:
print(traceback.format_exc())
continue
# Run when ready.
@client.event
async def on_ready():
print('Mejadi Framework Initialized...')
apihelper = apis.RequestEndpoints()
if apihelper.explorer_health != 200:
print('Failed to connect to AlgoExplorer API')
if apihelper.purestake_health != 200:
print('Failed to connect to PureStake API')
client.run(os.environ.get('MEJI_TOKEN'))