-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
52 lines (46 loc) · 1.5 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
# module imports
import discord
from discord.ext import commands
import asyncio
extensions = ['BasicCommands','debug','Moderation','music']
TOKEN = 'not today mr'
client = commands.Bot(command_prefix = '!')
@client.event
async def on_ready():
"""Runs when the bot is ready, prints to terminal"""
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.command()
async def load(ctx, extension):
"""Loads an extension"""
try:
client.load_extension(extension)
message = ('Loaded {}'.format(extension))
print(message)
await ctx.send(message)
except Exception as error:
error_loading = ("error loading [{}]".format(extension, error))
print(error_loading)
await ctx.send(error_loading)
@client.command()
async def unload(ctx, extension):
"""Unloads an extension"""
try:
client.unload_extension(extension)
message = ('Unloaded {}'.format(extension))
print(message)
await ctx.send(message)
except Exception as error:
error_loading = ("error unloading [{}]".format(extension, error))
print(error_loading)
await ctx.send(error_loading)
if __name__ == '__main__': #Fetches our cogs from the main file
for extension in extensions:
try:
client.load_extension(extension)
except Exception as error:
print("error loading [{}]".format(extension, error))
client.run(TOKEN, bot=True, reconnect=True)
asyncio.run(main())