Initial commit
This commit is contained in:
6
core/asyncHandler.py
Normal file
6
core/asyncHandler.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import aiohttp
|
||||
|
||||
async def get(url, json=True):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url) as response:
|
||||
return (await response.json()) if json else (await response.text())
|
||||
9
core/checks.py
Normal file
9
core/checks.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from .files import Data
|
||||
from discord.ext import commands
|
||||
|
||||
config = Data("config").yaml_read()
|
||||
|
||||
def manager():
|
||||
def predicate(ctx):
|
||||
return ctx.author.id in config["managers"]
|
||||
return commands.check(predicate)
|
||||
33
core/embeds.py
Normal file
33
core/embeds.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import random
|
||||
from discord import Embed, Color
|
||||
|
||||
class Embeds:
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def success(self, **kwargs):
|
||||
embed = Embed(
|
||||
description=self.message,
|
||||
color=Color.green()
|
||||
)
|
||||
for i in kwargs:
|
||||
embed.add_field(name=i.replace("_", " "), value=kwargs[i])
|
||||
return embed
|
||||
|
||||
def error(self, **kwargs):
|
||||
embed = Embed(
|
||||
description=self.message,
|
||||
color=Color.red()
|
||||
)
|
||||
for i in kwargs:
|
||||
embed.add_field(name=i.replace("_", " "), value=kwargs[i])
|
||||
return embed
|
||||
|
||||
def warn(self, **kwargs):
|
||||
embed = Embed(
|
||||
description=self.message,
|
||||
color=Color.orange()
|
||||
)
|
||||
for i in kwargs:
|
||||
embed.add_field(name=i.replace("_", " "), value=kwargs[i])
|
||||
return embed
|
||||
16
core/files.py
Normal file
16
core/files.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from yaml import load as yload, FullLoader
|
||||
from json import load as jload
|
||||
class Data:
|
||||
def __init__(self, filename:str):
|
||||
self.file = filename
|
||||
|
||||
def yaml_read(self):
|
||||
with open(f"data/{self.file}.yml", "r") as f:
|
||||
return yload(f, Loader=FullLoader)
|
||||
|
||||
def json_read(self):
|
||||
with open(f"data/{self.file}.json", "r") as f:
|
||||
return jload(f)
|
||||
|
||||
def read(self):
|
||||
return open(f"data/{self.file}.txt", "r").read()
|
||||
Reference in New Issue
Block a user