-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
54 lines (46 loc) · 1.54 KB
/
main.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
import discord
import yaml
try:
from heroku_git_fs import HerokuGitFS
except ModuleNotFoundError as e:
pass
from discord.ext import commands
import os
import shutil
if 'ON_HEROKU' not in os.environ:
config = yaml.safe_load(open('config.yaml'))
else:
config = {
'token': os.environ.get('TOKEN'),
'prefix': os.environ.get('PREFIX'),
'remote_url': os.environ.get('REMOTE_URL')
}
if 'remote_url' in config and os.path.isdir('databases'): # Only purge if the user specifies a remote URL while not on an ephemeral system
shutil.rmtree('databases')
elif not os.path.isdir('databases'):
os.makedirs('databases')
bot = commands.Bot(command_prefix=commands.when_mentioned_or(
config['prefix']),
description='A bot to make non Nitro members use non-global Nitro emotes on the servers it is in.',
pm_help=True)
def load_cog(cog):
try:
bot.load_extension(cog)
except Exception as e:
print('Could not load cog ' + cog)
print(e)
@bot.event
async def on_ready():
if 'remote_url' in config:
bot.heroku_git_fs = HerokuGitFS(remote_url=config['remote_url'], directory='databases', branch='master')
print('------------')
print('Logged in as:')
print(bot.user.name)
print(bot.user.id)
print('Using prefix:')
print(config['prefix'])
print('------------')
load_cog('animotes')
print('Loaded animotes cog...')
await bot.change_presence(activity=discord.Game(name='Use ' + config['prefix'] + 'register to enable me'))
bot.run(config['token'])