-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot.py
More file actions
33 lines (24 loc) · 812 Bytes
/
bot.py
File metadata and controls
33 lines (24 loc) · 812 Bytes
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
import json
import os
import traceback
import discord
from discord.ext import commands
with open('config.json') as f:
config = json.load(f)
class Bot(commands.AutoShardedBot):
def __init__(self, **options):
super().__init__(**options)
self._load_cogs()
def _load_cogs(self):
for ext in os.listdir('extensions'):
if ext.endswith('.py'):
try:
self.load_extension(f'extensions.{ext[:-3]}')
except (ImportError, SyntaxError, discord.ClientException):
traceback.print_exc()
async def on_message(self, message):
if message.author.bot:
return
await self.process_commands(message)
bot = Bot(command_prefix=config.get('prefixes'))
bot.run(config.get('token'))