-
Notifications
You must be signed in to change notification settings - Fork 5
/
bot.py
67 lines (46 loc) · 1.7 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
from discord.ext import commands
import discord
import logging
import datetime
import config
import json
import asyncio
import subprocess
from multiprocessing import Pool
extensions = [
"cogs.utils",
"cogs.src",
"cogs.tas",
"cogs.admin"
]
class CelesteBot(commands.Bot):
async def load_extensions(self):
for extension in extensions:
await self.load_extension(extension)
def __init__(self):
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
super().__init__(command_prefix='!', intents=intents)
self.logger = logging.getLogger('discord')
with open('custom_commands.json', 'r') as f:
self.custom_commands = json.load(f)
asyncio.get_event_loop().run_until_complete(self.load_extensions())
async def on_member_join(self, member):
await member.guild.get_channel(805370260957429780).send("Welcome! <:yadelie:642375995961114636>")
async def on_ready(self):
self.uptime = datetime.datetime.utcnow()
game = discord.Game("gemskip 2400m")
await self.change_presence(activity=game)
self.logger.warning(f'Online: {self.user} (ID: {self.user.id})')
async def on_message(self, message):
if message.author.bot:
return
if message.content:
command = message.content.split()[0]
if command in self.custom_commands:
await message.channel.send(self.custom_commands[command])
return
await self.process_commands(message)
async def run(self):
await super().start(config.token, reconnect=True)