From 99faea0dc5de78c455517997c2c1b176c1da6396 Mon Sep 17 00:00:00 2001 From: Random Guy JCI <22722393+RandomGuyJCI@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:23:50 +0800 Subject: [PATCH] fix duplicate attachment names being shown in reactx --- .../bot/handlers/interactions/commands/reactx.py | 15 +++++++-------- orchard/bot/lib/utils.py | 4 +++- orchard/scan/scan.py | 1 - 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/orchard/bot/handlers/interactions/commands/reactx.py b/orchard/bot/handlers/interactions/commands/reactx.py index 995e60d..30bd356 100644 --- a/orchard/bot/handlers/interactions/commands/reactx.py +++ b/orchard/bot/handlers/interactions/commands/reactx.py @@ -10,7 +10,6 @@ async def _reactx(body, _): async with Interactor(body["token"]) as interactor: channel_id = body["channel_id"] - token = body["token"] user_id = body["member"]["user"]["id"] bot_id = body["application_id"] messages = body["data"]["resolved"]["messages"] @@ -34,25 +33,25 @@ async def _reactx(body, _): for attachment in value["attachments"] if attachment["filename"].endswith(".rdzip") ] - for i, reaction in enumerate(number_reactions): + for i, attachment in enumerate(rdzip_attachments): if "reactions" not in value: continue - if reaction not in [ + if number_reactions[i] not in [ react["emoji"]["name"] for react in value["reactions"] ]: continue - if i >= len(rdzip_attachments): - continue reaction_users = await interactor.get_reactions( - channel_id, message_id, reaction + channel_id, message_id, number_reactions[i] ) for reactor in reaction_users.json(): if bot_id == reactor["id"]: ignored_rdzips.append(rdzip_attachments[i]) - continue + break if user_id == reactor["id"]: ignored_rdzips.append(rdzip_attachments[i]) - await interactor.react(channel_id, message_id, reaction) + await interactor.react( + channel_id, message_id, number_reactions[i] + ) await interactor.react(channel_id, message_id, "🚫") result = "Done, now ignoring all rdzips." if len(ignored_rdzips) > 0: diff --git a/orchard/bot/lib/utils.py b/orchard/bot/lib/utils.py index ddf1de2..1b47f5e 100644 --- a/orchard/bot/lib/utils.py +++ b/orchard/bot/lib/utils.py @@ -16,7 +16,9 @@ def get_slash_args(args, body): options = body["data"]["options"] options_dict = {option["name"]: option["value"] for option in options} return [options_dict[arg] if arg in options_dict else None for arg in args] - except KeyError: # No arguments were given (e.g. all arguments are optional and we didn't get any of them) + except ( + KeyError + ): # No arguments were given (e.g. all arguments are optional and we didn't get any of them) return [None for _ in args] diff --git a/orchard/scan/scan.py b/orchard/scan/scan.py index b3bf66e..6af3034 100644 --- a/orchard/scan/scan.py +++ b/orchard/scan/scan.py @@ -25,7 +25,6 @@ async def main(db: SqliteExtDatabase, sources): - Level.bind(db) if not db.table_exists("level"):