-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot_core.py
More file actions
40 lines (26 loc) · 1.13 KB
/
bot_core.py
File metadata and controls
40 lines (26 loc) · 1.13 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
import discord
import os
from discord.ext import commands
from bot_functions import load_config
CONFIG_FILE = os.path.join(os.path.abspath(os.curdir), 'bot_config.json')
CONFIG_TOKEN = 'Bot Token'
config_json = load_config(CONFIG_FILE)
TOKEN = config_json[CONFIG_TOKEN] # Loads the bot's token from a configuration file.
def get_prefix(bot, message):
prefixes = ['!']
# If we are in a guild, we allow for the user to mention us or use any of the prefixes in our list.
return commands.when_mentioned_or(*prefixes)(bot, message)
extensions = ['cogs.perpetuum_killboard_cog']
# The bot modules we wish to load. The dot represents folders.
bot = commands.Bot(command_prefix=get_prefix, description='Perpetuum Killboard Bot')
for extension in extensions:
try:
bot.load_extension(extension)
except Exception as e:
print(f'Failed to load extension {extension}.')
@bot.event
async def on_ready():
print(f'\nLogged in as: {bot.user.name} - {bot.user.id}\nVersion: {discord.__version__}\n')
print(f'Successfully logged in and booted...!')
if __name__ == '__main__':
bot.run(TOKEN, bot=True, reconnect=True)