-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquotebot.py
More file actions
executable file
·54 lines (43 loc) · 1.35 KB
/
quotebot.py
File metadata and controls
executable file
·54 lines (43 loc) · 1.35 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
#!/usr/bin/env python3
import discord
import json
from lib.db_helper import DBHelper
from discord.ext import commands
print("Loading quotebot...")
# Read our bot token from the configuration file
with open('config.json') as cfg_file:
print("Reading configuration file...")
cfg = json.load(cfg_file)
# Set up our bot insance
bot = commands.Bot(command_prefix=commands.when_mentioned,
owner_id=cfg['owner_id'])
# Initialize our DB Helper object
bot.dbh = DBHelper(cfg['db_file'])
@bot.event
async def on_ready():
"""Actions executed when the bot is logged in and available.
"""
print(f"Logged in as {bot.user.name}#{bot.user.discriminator}")
print(f"> Connected to {len(bot.guilds)} guilds")
if __name__ == '__main__':
# Load all our cogs, then run the bot
print("Loading extensions...")
bot.ext_names = [
'cogs.ping',
'cogs.stats',
'cogs.guild_config',
'cogs.quote',
'cogs.unquote',
'cogs.reload',
'cogs.invite',
]
for extension in bot.ext_names:
try:
bot.load_extension(extension)
except Exception as e:
print(f"> Failed to load extension {extension}")
raise e
else:
print(f"> Loaded {extension[5:]}")
print("Starting quotebot...")
bot.run(cfg['token'], reconnect=True)