-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
36 lines (27 loc) · 981 Bytes
/
config.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
import os
import discord
import motor.motor_asyncio
from discord.ext import commands
TOKEN = os.getenv("DISCORD_TOKEN")
STAGE = os.getenv("STAGE", "dev")
LOG_LEVEL = os.getenv("LOG_LEVEL", "WARNING")
mongo_client = motor.motor_asyncio.AsyncIOMotorClient("mongodb")
db = mongo_client["discord"]
# Common command checks
async def get_prefix(guild: discord.Guild):
# Only allow prefixs in guild
if guild:
guilds_col = db["guilds"]
current_guild = await guilds_col.find_one({"guild_id": guild.id})
if current_guild is None or "prefix" not in current_guild.keys():
# default prefix
return "?="
return current_guild["prefix"]
return ""
def is_admin():
async def predicate(ctx):
if ctx.message.author.guild_permissions.administrator:
return True
await ctx.send("This is an admin-only command <a:NOP:799726788132732928>")
return False
return commands.check(predicate)