Skip to content

Commit

Permalink
Apply Linting & Formatting Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
someyuck authored and github-actions[bot] committed Apr 13, 2024
1 parent 09af324 commit 0b2bd46
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- `verify_user()`: Implements `.verify`.
- `backend_info()`: Logs server details for debug purposes (bot admin only).
- `backend_info_error()`: Replies with error message is user is not a bot admin.
- `is_academic_or_bot_admin()`: Checks if server is for academic use or if the
- `is_academic_or_bot_admin()`: Checks if server is for academic use or if the
author of the message is a bot admin or not.
- `query()`: Returns user details, uses Discord ID to find in DB (bot admin-able).
- `query_error()`: Replies eror message if server is not academic and the user is not a bot admin.
Expand Down Expand Up @@ -247,7 +247,11 @@ async def backend_info(ctx):
@backend_info.error
async def backend_info_error(ctx, error):
"""If the author of the message is not a bot admin then reply accordingly."""
if isinstance(error, commands.CheckFailure) and isinstance(error.original, CheckFailedException) and error.original.check_name == "is_author_bot_admin":
if (
isinstance(error, commands.CheckFailure)
and isinstance(error.original, CheckFailedException)
and error.original.check_name == "is_author_bot_admin"
):
author_id = str(ctx.message.author.id)
await ctx.reply(f"{author_id} is not a bot admin.")
else:
Expand All @@ -272,8 +276,8 @@ async def query(
identifier: discord.User,
):
"""
First checks if the server is an academic one or if the user who invoked the
command is a bot admin. If so, finds that user (by Discord ID) in the DB.
First checks if the server is an academic one or if the user who invoked the
command is a bot admin. If so, finds that user (by Discord ID) in the DB.
If present, replies with their name, email and roll number.
Otherwise replies telling the user they are not registed with CAS.
"""
Expand All @@ -289,12 +293,18 @@ async def query(
@query.error
async def query_error(ctx, error):
"""
For the `query` command, if the server is not academic and the invoking user is not a bot
For the `query` command, if the server is not academic and the invoking user is not a bot
admin, replies with error message.
"""
if isinstance(error, commands.CheckFailure) and isinstance(error.original, CheckFailedException) and error.original.check_name == "is_academic_or_bot_admin":
if (
isinstance(error, commands.CheckFailure)
and isinstance(error.original, CheckFailedException)
and error.original.check_name == "is_academic_or_bot_admin"
):
author_id = str(ctx.message.author.id)
await ctx.reply(f"This server is not for academic purposes and {author_id} is not a bot admin.")
await ctx.reply(
f"This server is not for academic purposes and {author_id} is not a bot admin."
)
else:
await ctx.reply("Some check failed.")

Expand All @@ -306,9 +316,9 @@ async def roll(
identifier: int,
):
"""
First checks if the server is an academic one or if the user who invoked the
command is a bot admin If so, finds that user in the DB. If present, replies
with their name, email and roll number. Otherwise replies telling the user
First checks if the server is an academic one or if the user who invoked the
command is a bot admin If so, finds that user in the DB. If present, replies
with their name, email and roll number. Otherwise replies telling the user
they are not registed with CAS.
Same as the `query` command, except this searches by roll number instead of Discord ID.
Expand All @@ -328,9 +338,15 @@ async def roll_error(ctx, error):
For the `roll` command, if the server is not academic and the ivoking user is not a bot admin,
replies with error message.
"""
if isinstance(error, commands.CheckFailure) and isinstance(error.original, CheckFailedException) and error.original.check_name == "is_academic_or_bot_admin":
if (
isinstance(error, commands.CheckFailure)
and isinstance(error.original, CheckFailedException)
and error.original.check_name == "is_academic_or_bot_admin"
):
author_id = str(ctx.message.author.id)
await ctx.reply(f"This server is not for academic purposes and {author_id} is not a bot admin.")
await ctx.reply(
f"This server is not for academic purposes and {author_id} is not a bot admin."
)
else:
await ctx.reply("Some check failed.")

Expand Down

0 comments on commit 0b2bd46

Please sign in to comment.