Skip to content

Commit

Permalink
fix duplicate attachment names being shown in reactx
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomGuyJCI committed Oct 9, 2024
1 parent 8d20d53 commit 99faea0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
15 changes: 7 additions & 8 deletions orchard/bot/handlers/interactions/commands/reactx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion orchard/bot/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
1 change: 0 additions & 1 deletion orchard/scan/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


async def main(db: SqliteExtDatabase, sources):

Level.bind(db)

if not db.table_exists("level"):
Expand Down

0 comments on commit 99faea0

Please sign in to comment.