From 1e4472898081658c45c559f0fe121af99a6fa20b Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Sat, 14 Dec 2019 01:36:20 -0900 Subject: [PATCH] Change decorator which checks for owner Add is_me decorator to checks.py --- geeksbot/__main__.py | 9 ++++++--- geeksbot/imports/checks.py | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/geeksbot/__main__.py b/geeksbot/__main__.py index df6cd09..05e78af 100644 --- a/geeksbot/__main__.py +++ b/geeksbot/__main__.py @@ -66,6 +66,8 @@ logger.info(f'Misc Libs Import Complete - Took {(datetime.utcnow() - start).tota # from geeksbot.imports import message_logging # logger.info(f'Geeksbot Libs Import Complete - Took {(datetime.utcnow() - start).total_seconds()} seconds') +from geeksbot.imports.checks import is_me + logger.info('Imports Complete') @@ -94,6 +96,7 @@ class Geeksbot(commands.Bot): self.geo_api = '2d4e419c2be04c8abe91cb5dd1548c72' self.git_url = 'https://github.com/dustinpianalto/geeksbot_v2' self.load_default_extensions() + self.owner_id = 351794468870946827 self.book_emojis = { 'unlock': '🔓', @@ -125,8 +128,8 @@ class Geeksbot(commands.Bot): bot = Geeksbot(case_insensitive=True) +@is_me() @bot.command(hidden=True) -@commands.is_owner() async def load(ctx, mod=None): """Allows the owner to load extensions dynamically""" logger.info(f"Starting to load {mod}") @@ -135,8 +138,8 @@ async def load(ctx, mod=None): logger.info(f"{mod} loaded") +@is_me() @bot.command(hidden=True) -@commands.is_owner() async def reload(ctx, mod=None): """Allows the owner to reload extensions dynamically""" if mod == 'all': @@ -151,8 +154,8 @@ async def reload(ctx, mod=None): await ctx.send(f'{mod} reloaded') +@is_me() @bot.command(hidden=True) -@commands.is_owner() async def unload(ctx, mod): """Allows the owner to unload extensions dynamically""" logger.info(f"Starting to unload {mod}") diff --git a/geeksbot/imports/checks.py b/geeksbot/imports/checks.py index 1543645..b9d77bb 100644 --- a/geeksbot/imports/checks.py +++ b/geeksbot/imports/checks.py @@ -1,4 +1,7 @@ import discord -def is_rcon_admin(bot, ctx): - \ No newline at end of file + +def is_me(): + def predicate(ctx): + return ctx.message.author.id == ctx.bot.owner_id + return discord.ext.commands.check(predicate)