This repository has been archived by the owner on Jan 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiscordCity.py
65 lines (50 loc) · 1.9 KB
/
DiscordCity.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
import asyncio
import pickle
import sys
import traceback
import discord
from discord.ext import commands
class DiscordCity(commands.Bot):
def __init__(self):
super().__init__(
command_prefix=self._get_prefix,
description="A bot for Discord Hack Week.\nGenerates a city out of the current server."
)
self.owner_ids = [
270190067354435584, # green
334350969196380160, # fish
389814953562996736, # kat
286546315003953152 # Incog
]
self.initial_extensions = ["cogs.info", "cogs.owner", "cogs.eh", "cogs.city"]
self.load_exts()
def _get_prefix(self, bot, message):
if not message.guild:
return ['asfajaskdaj']
else:
prefix = ['~']
return commands.when_mentioned_or(*prefix)(bot, message)
def load_exts(self):
for extension in self.initial_extensions:
try:
self.load_extension(extension)
print(f"Successfully loaded extension - {extension}")
except Exception:
print(
f"Failed to load extension - {extension}", file=sys.stderr)
traceback.print_exc()
async def is_owner(self, user):
return user.id in self.owner_ids
async def on_ready(self):
await self.change_presence(activity=discord.Activity(name="Building Cities...", type=discord.ActivityType.playing))
print(f"\n\nLogged in as: {self.user.name} - {self.user.id}")
print(f"Version: {discord.__version__}\n")
def run(self):
print("Connecting to discordapp")
with open("tooken.data", "rb") as f:
tooken = pickle.load(f)
super().run(tooken, bot=True, reconnect=True)
if __name__ == "__main__":
if "win" in sys.platform:
asyncio.set_event_loop(asyncio.ProactorEventLoop())
DiscordCity().run()