-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbot.py
98 lines (72 loc) · 2.81 KB
/
bot.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# bot.py
# driver for the bot
# is the brains of this whole operation
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
intents = discord.Intents(guilds = True, emojis = True, members = True, messages = True, reactions = True, typing = True)
load_dotenv()
TOKEN = os.getenv('IKA_TOKEN') #obtains bot token from .env file
bot = commands.Bot(command_prefix = ('m.', 'M.', '<@!705683895055679521> ', '<@!705683895055679521>'), intents = intents)
bot.remove_command('help')
# loads cogs
@bot.command()
async def load(ctx, extension):
if ctx.author.id != 275065846836101120:
await ctx.message.add_reaction('👎')
return
else:
await ctx.message.add_reaction('👍')
bot.load_extension(f'commands.{extension}')
# unloads cogs
@bot.command()
async def unload(ctx, extension):
if ctx.author.id != 275065846836101120:
await ctx.message.add_reaction('👎')
return
await ctx.message.add_reaction('👍')
bot.unload_extension(f'commands.{extension}')
# reloads the cogs
@bot.command()
async def reload(ctx, extension = ''):
if ctx.author.id != 275065846836101120:
await ctx.message.add_reaction('👎')
return
elif extension == '':
for filename in os.listdir('./commands/general'):
if filename.endswith('.py'):
bot.reload_extension(f'commands.general.{filename[:-3]}')
for filename in os.listdir('./commands/img'):
if filename.endswith('.py'):
bot.reload_extension(f'commands.img.{filename[:-3]}')
for filename in os.listdir('./commands/mal_anilist'):
if filename.endswith('.py'):
bot.reload_extension(f'commands.mal_anilist.{filename[:-3]}')
for filename in os.listdir('./commands/misc'):
if filename.endswith('.py'):
bot.reload_extension(f'commands.misc.{filename[:-3]}')
for filename in os.listdir('./commands/src'):
if filename.endswith('.py'):
bot.reload_extension(f'commands.src.{filename[:-3]}')
await ctx.message.add_reaction('👍')
else:
await ctx.message.add_reaction('👍')
bot.reload_extension(f'commands.{extension}')
#Load all cogs when bot starts
for filename in os.listdir('./commands/general'):
if filename.endswith('.py'):
bot.load_extension(f'commands.general.{filename[:-3]}')
for filename in os.listdir('./commands/img'):
if filename.endswith('.py'):
bot.load_extension(f'commands.img.{filename[:-3]}')
for filename in os.listdir('./commands/mal_anilist'):
if filename.endswith('.py'):
bot.load_extension(f'commands.mal_anilist.{filename[:-3]}')
for filename in os.listdir('./commands/misc'):
if filename.endswith('.py'):
bot.load_extension(f'commands.misc.{filename[:-3]}')
for filename in os.listdir('./commands/src'):
if filename.endswith('.py'):
bot.load_extension(f'commands.src.{filename[:-3]}')
bot.run(TOKEN)