Code Cleanup
This commit is contained in:
parent
d2622e25e8
commit
fa34f8510d
13 changed files with 98 additions and 50 deletions
|
@ -1,8 +1,13 @@
|
|||
'''
|
||||
This module will provide permission checks
|
||||
for the command executions.
|
||||
'''
|
||||
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from util import logging
|
||||
|
||||
def is_author_bot(ctx : commands.Context):
|
||||
def is_author_bot(ctx : commands.Context) -> bool:
|
||||
if ctx.message.author.bot:
|
||||
return False
|
||||
return True
|
|
@ -1,10 +1,15 @@
|
|||
'''
|
||||
This module loads settings. Right now
|
||||
it can only hold one config file at a time
|
||||
'''
|
||||
|
||||
import json
|
||||
from util import logging
|
||||
|
||||
filepath = ""
|
||||
settings = {}
|
||||
|
||||
def load(file):
|
||||
def load(file : str) -> bool:
|
||||
global settings
|
||||
filepath = file
|
||||
try:
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
'''
|
||||
Provides some simple logging utility
|
||||
'''
|
||||
import datetime
|
||||
|
||||
path = "logs/log.txt"
|
||||
cleanup = open(path, "w+")
|
||||
cleanup.close()
|
||||
|
||||
def log(msg, log_type, mute):
|
||||
# Format: [DD.MM.YYYY HH:MM:SS] [<TYPE>] MESSAGE
|
||||
def log(msg: str, log_type: str, mute: bool):
|
||||
log = f"[{datetime.datetime.now().strftime('%d.%m.%Y %H:%M:%S')}] [{log_type.upper()}] {msg}"
|
||||
log_file = open(path, "a")
|
||||
log_file.write(log + "\n")
|
||||
|
@ -12,11 +16,11 @@ def log(msg, log_type, mute):
|
|||
if mute == False:
|
||||
print(log)
|
||||
|
||||
def info(msg, mute=False):
|
||||
def info(msg: str, mute: bool=False):
|
||||
log(msg, "info", mute)
|
||||
|
||||
def warning(msg, mute=False):
|
||||
def warning(msg: str, mute: bool=False):
|
||||
log(msg, "warning", mute)
|
||||
|
||||
def error(msg, mute=False):
|
||||
def error(msg: str, mute: bool=False):
|
||||
log(msg, "error", mute)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue