mostly working idfk
This commit is contained in:
parent
b0ba03f97d
commit
4e111b410d
12 changed files with 822 additions and 291 deletions
37
modules/permission.py
Normal file
37
modules/permission.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from functools import wraps
|
||||
import discord
|
||||
|
||||
import discord.ext
|
||||
import discord.ext.commands
|
||||
|
||||
from modules.settings import Settings as SettingsManager
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("goober")
|
||||
|
||||
settings_manager = SettingsManager()
|
||||
settings = settings_manager.settings
|
||||
|
||||
|
||||
class PermissionError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def requires_admin():
|
||||
async def wrapper(ctx: discord.ext.commands.Context):
|
||||
if ctx.author.id not in settings["bot"]["owner_ids"]:
|
||||
await ctx.send(
|
||||
"You don't have the necessary permissions to run this command!"
|
||||
)
|
||||
return False
|
||||
|
||||
command = ctx.command
|
||||
if not command:
|
||||
logger.info(f"Unknown command ran {ctx.message}")
|
||||
else:
|
||||
logger.info(
|
||||
f'Command {settings["bot"]["prefix"]}{command.name} @{ctx.author.name}'
|
||||
)
|
||||
return True
|
||||
|
||||
return discord.ext.commands.check(wrapper)
|
Loading…
Add table
Add a link
Reference in a new issue