forked from PhoqueEberlue/DiscordMiniGames
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
54 lines (40 loc) · 1.6 KB
/
Copy pathbot.py
File metadata and controls
54 lines (40 loc) · 1.6 KB
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
import os
from discord.ext import commands
from tokenConfig import getToken
bot = commands.Bot(command_prefix='$')
@bot.event
async def on_ready():
print('bot is ready')
@bot.event
async def on_guild_join(self, guild):
await guild.create_role(name="Discord Mini Games Admin")
@bot.command()
async def load(ctx: commands.Context, extension):
if ctx.author.id == 205434999888019456:
try:
bot.load_extension(f'games.{extension}.Cog{extension}')
await ctx.send(f'{extension} module has been loaded')
except ModuleNotFoundError as error:
await ctx.send(f'{error}')
@bot.command()
async def unload(ctx: commands.Context, extension):
if ctx.author.id == 205434999888019456:
try:
bot.unload_extension(f'games.{extension}.Cog{extension}')
await ctx.send(f'{extension} module has been unloaded')
except commands.errors.ExtensionNotLoaded as error:
await ctx.send(f'{error}')
@bot.command()
async def refresh(ctx: commands.Context, extension):
if ctx.author.id == 205434999888019456:
try:
bot.reload_extension(f'games.{extension}.Cog{extension}')
await ctx.send(f'{extension} module has been refreshed')
except commands.errors.ExtensionNotLoaded as error:
await ctx.send(f'{error}')
# Loads up every cogs in the ./games file
for rep in os.listdir('./games'):
for file_name in os.listdir('./games/' + rep):
if file_name.startswith('Cog') and file_name.endswith('.py'):
bot.load_extension(f'games.{rep}.{file_name[:-3]}')
bot.run(getToken())