From 7118a80d5ddf8a3f30d772b33c2548d72c9a5728 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Wed, 14 Apr 2021 18:07:09 +0200 Subject: [PATCH] Replace isMe with isOwner to allow other people to debug their own bot --- cogs/train.py | 2 +- functions/checks.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cogs/train.py b/cogs/train.py index 7a4ebb6..093a096 100644 --- a/cogs/train.py +++ b/cogs/train.py @@ -89,7 +89,7 @@ class Train(commands.Cog): return "".join(arr) async def sendEmbed(self, ctx, embed): - if checks.allowedChannels(ctx): + if await checks.allowedChannels(ctx): await ctx.send(embed=embed) else: await ctx.author.send(embed=embed) diff --git a/functions/checks.py b/functions/checks.py index ea68c46..a3c82cd 100644 --- a/functions/checks.py +++ b/functions/checks.py @@ -8,22 +8,23 @@ import requests from functions.database import currency -# Checks if caller of a command is me -def isMe(ctx): - return str(ctx.author.id) == constants.myId +# Checks if caller of a command is the owner of the bot +async def isMe(ctx): + # return str(ctx.author.id) == constants.myId + return await ctx.bot.is_owner(ctx.author) # Checks if the caller of a command is an admin -def isMod(ctx): +async def isMod(ctx): if ctx.guild is None: - return isMe(ctx) + return await isMe(ctx) return ctx.author.id in constants.mods[ctx.guild.id] # Checks if a command is allowed to be used in this channel -def allowedChannels(ctx): - return isMe(ctx) or ctx.channel.type == discord.ChannelType.private or int(ctx.channel.id) in constants.allowedChannels.values() +async def allowedChannels(ctx): + return (await isMe(ctx)) or ctx.channel.type == discord.ChannelType.private or int(ctx.channel.id) in constants.allowedChannels.values() # TODO find a better way to check for legit links because reddit posts return a 502