-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
43 lines (36 loc) · 1.16 KB
/
bot.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
import discord
import sys
from discord.ext import commands
import botconfig
def get_prefix(bot, message):
"""A callable Prefix for our bot. This could be edited to allow per server prefixes."""
prefixes = botconfig.config['prefixes']
return commands.when_mentioned_or(*prefixes)(bot, message)
# Define all of our cogs
initial_extensions = [ 'cogs.loader'
, 'cogs.poll' # poll on dev
]
bot = commands.Bot(command_prefix=get_prefix)
# Here we load our extensions(cogs) listed above in [initial_extensions].
if __name__ == '__main__':
for extension in initial_extensions:
bot.load_extension(extension)
@bot.event
async def on_ready():
print('------')
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
print('Discord.py version')
print(discord.__version__)
print('------')
try:
await bot.change_presence(activity=discord.Game(name="spooky scary skeleton"))
except TypeError as type_err:
print ("Error TypeError : {}".format(type_err))
sys.exit(0)
except :
print ("Error {}".format(sys.exc_info()[0]))
sys.exit(0)
bot.run(botconfig.config['token'])