Skip to content

Commit

Permalink
Fixed is_banned check breaking on DM's
Browse files Browse the repository at this point in the history
  • Loading branch information
LobaDK committed May 18, 2024
1 parent 0c8abab commit fdd8d4e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions QuantumKat.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ async def init_models():
await conn.run_sync(models.Base.metadata.create_all)



log_helper = LogHelper()
misc_helper = MiscHelper()
discord_helper = DiscordHelper()
Expand Down Expand Up @@ -91,7 +90,7 @@ async def setup(bot: commands.Bot):


async def is_authenticated(ctx: commands.Context) -> bool:
if ctx.author.id == int(OWNER_ID):
if ctx.author.id in bot.owner_ids:
return True
if not ctx.command.name.casefold() == "request_auth":
authenticated_server_ids = await crud.get_authenticated_servers(
Expand Down Expand Up @@ -119,7 +118,7 @@ async def is_authenticated(ctx: commands.Context) -> bool:


async def is_reboot_scheduled(ctx: commands.Context) -> bool:
if ctx.author.id == int(OWNER_ID):
if ctx.author.id in bot.owner_ids:
return True
if bot.reboot_scheduled:
await ctx.reply(
Expand All @@ -131,26 +130,28 @@ async def is_reboot_scheduled(ctx: commands.Context) -> bool:


async def is_banned(ctx: commands.Context) -> bool:
if ctx.author.id == int(OWNER_ID):
if ctx.author.id in bot.owner_ids:
return True
user = await crud.get_user(
AsyncSessionLocal, schemas.User.Get(user_id=ctx.author.id)
)
server = await crud.get_server(
AsyncSessionLocal, schemas.Server.Get(server_id=ctx.guild.id)
)
if user and user.is_banned:
await ctx.reply(
"You have been banned from using QuantumKat. Please contact the bot owner for more information.",
silent=True,
)
return False
if server and server.is_banned:
await ctx.reply(
"This server has been banned from using QuantumKat. Please contact the bot owner for more information.",
silent=True,

if not discord_helper.is_dm(ctx):
server = await crud.get_server(
AsyncSessionLocal, schemas.Server.Get(server_id=ctx.guild.id)
)
return False
if server and server.is_banned:
await ctx.reply(
"This server has been banned from using QuantumKat. Please contact the bot owner for more information.",
silent=True,
)
return False
return True


Expand Down

0 comments on commit fdd8d4e

Please sign in to comment.