This repository was archived by the owner on Oct 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.py
More file actions
44 lines (34 loc) · 1.19 KB
/
app.py
File metadata and controls
44 lines (34 loc) · 1.19 KB
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
import os
import time
import discord
from discord.ext import commands, tasks, ipc
import config
from utils import database
async def get_server_prefix(bot, message):
if message.guild:
prefix = database.get_config(message.guild.id)["prefix"]
return prefix
else:
return "."
class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args,**kwargs)
self.ipc = ipc.Server(self, secret_key=config.ipc_key)
async def on_ipc_ready(self):
print("> IPC server ready.")
async def on_ipc_error(self, endpoint, error):
print(endpoint, "raised", error)
bot = Bot(command_prefix=get_server_prefix, intents=discord.Intents.all())
@bot.event
async def on_ready():
database.setup_database()
print("> Bot is now running.")
@bot.event
async def on_command(ctx):
print(f"> [{database.get_date_time()}] Command '{ctx.command.name}' executed by {ctx.author.name} in guild '{ctx.guild}' ({ctx.guild.id}).")
for file in os.listdir("./modules"):
if file.endswith(".py"):
print(f"'{file}' has been loaded successfully.")
bot.load_extension(f"modules.{file[:-3]}")
bot.ipc.start()
bot.run(config.token)