-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (33 loc) · 1.39 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
import discord
from discord.ext import commands
import asyncio
# configuration files
import configparser
import sys, traceback
# load configuration to get around hard coded tokens
config = configparser.ConfigParser()
with open('config.ini') as config_file:
config.read_file(config_file)
# startup stuff
print(f'discordpy version: {discord.__version__}')
client = commands.Bot(command_prefix='$', description='Utility bot for the UWB ACM Discord server. View source at '
'github.com/UWB-ACM/ACMBot')
default_extensions = ['cogs.base', 'cogs.trelloActivity']
if __name__ == '__main__':
for extension in default_extensions:
try:
client.load_extension(extension)
except Exception as e:
print(f'Failed to load extension {extension}.', file=sys.stderr)
traceback.print_exc()
@client.event
async def on_member_join(member):
await client.send_message(member, 'Welcome to the ACM Officer Discord server! :tada:')
@client.event
async def on_ready():
# print some stuff when the bot goes online
print(f'Logged in {client.user.name} - {client.user.id}\nVersion {discord.__version__}')
await client.change_presence(activity=discord.Game(name='Try $help'))
# now actually connect the bot
client.run(config.get(section='Configuration', option='connection_token'),
bot=True, reconnect=True)