forked from unswpcsoc/PCSocBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
executable file
·92 lines (71 loc) · 2.89 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
import commands
#from commands.highnoon import high_noon, HIGH_NOON_CHANNEL
#from commands.leaderboard import leaderboard, LEADERBOARD_CHANNEL
from commands.twitch import twitch, TWITCH_CHANNEL
from configstartup import config
# from commands.report import report, REPORT_CHANNEL
# from commands.whitelist import check_whitelist, WHITELIST_CHANNEL
from commands.emoji import emojistats
# from commands.birthday import update_birthday
import asyncio
import json
import os
import sys
import discord
client = discord.Client()
high_noon_channel = None
report_channel = None
DEFAULT_PRESENCE = "!helpme"
err = """OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo!
The code monkeys at our headquarters are working VEWY HAWD to fix this!"""
@client.event
async def on_ready():
# Set game by CLA or default
presence = sys.argv[1] if len(sys.argv) == 2 else DEFAULT_PRESENCE
print('------')
print('Logged in as')
print(client.user.name)
print(client.user.id)
print("Playing " + presence)
print('------')
global report_channel
await client.change_presence(activity=discord.Game(presence))
# Birthday checking!
# asyncio.ensure_future(update_birthday(client))
for channel in client.get_all_channels():
# if channel.name == HIGH_NOON_CHANNEL:
# await high_noon(client, channel)
# if channel.name == LEADERBOARD_CHANNEL:
#asyncio.ensure_future(leaderboard(client, channel))
if channel.id == TWITCH_CHANNEL:
asyncio.ensure_future(twitch(client, channel))
# if channel.id == REPORT_CHANNEL:
# report_channel = channel
# if channel.id == WHITELIST_CHANNEL:
# asyncio.ensure_future(check_whitelist(client, channel))
@client.event
async def on_message(message):
try:
# if report_channel and await report(client, report_channel, message):
# return
await emojistats(message)
if message.content.startswith(commands.PREFIX) and message.author != client.user:
args = '\\n '.join(message.content[1:].splitlines()).split()
if args:
cls, args = commands.Helpme.find_command(args)
if not cls.disabled:
# Command is enabled
output = await cls(client, message).init(*args)
if isinstance(output, discord.Embed):
await message.channel.send(embed=output)
elif output is not None:
if isinstance(output, list):
for msg in output:
await message.channel.send(msg)
else:
await message.channel.send(output)
except discord.errors.HTTPException as e:
print(e)
await message.channel.send(err)
client.run(config['KEYS'].get('DiscordToken'))