Remove question mark reaction (#86)
* Update __init__.py Setting `do_query_message` to accept full payload * Update proxy.py Adding code to remove question mark reaction after sending the message card * Update proxy.py Fixing type declaration in recent changes * Fixing message grab Getting the channel the reaction was handled in and changing the `fetch_message` call to grab from the channel * Adding back pronouns option Not sure why it was removed, honestly * Fixing issues caused by PK using an outdated version of the lib. Whoops :')
This commit is contained in:
		| @@ -112,7 +112,7 @@ def run(config: Config): | ||||
|                 await proxy.try_delete_by_reaction(conn, client, payload.message_id, payload.user_id, logger) | ||||
|         if payload.emoji.name in "\u2753\u2754":  # Question mark | ||||
|             async with pool.acquire() as conn: | ||||
|                 await proxy.do_query_message(conn, client, payload.user_id, payload.message_id) | ||||
|                 await proxy.do_query_message(conn, client, payload) | ||||
|  | ||||
|     @client.event | ||||
|     async def on_error(event_name, *args, **kwargs): | ||||
|   | ||||
| @@ -233,22 +233,26 @@ async def try_delete_by_reaction(conn, client: discord.Client, message_id: int, | ||||
|  | ||||
|     await handle_deleted_message(conn, client, message_id, original_message.content, logger) | ||||
|  | ||||
| async def do_query_message(conn, client: discord.Client, queryer_id: int, message_id: int) -> bool: | ||||
| async def do_query_message(conn, client: discord.Client, payload: discord.RawReactionActionEvent) -> bool: | ||||
|     # Find the message that was queried | ||||
|     msg = await db.get_message(conn, message_id) | ||||
|     msg = await db.get_message(conn, payload.message_id) | ||||
|     if not msg: | ||||
|         return False | ||||
|  | ||||
|     # Then DM the queryer the message embed | ||||
|     card = await embeds.message_card(client, msg, include_pronouns=True) | ||||
|     user = client.get_user(queryer_id) | ||||
|     user = client.get_user(payload.user_id) | ||||
|     if not user: | ||||
|         # We couldn't find this user in the cache - bail | ||||
|         return False | ||||
|      | ||||
|     # Send the card to the user | ||||
|     # Remove reaction and send the card to the user | ||||
|     try: | ||||
|         channel = await client.get_channel(payload.channel_id) | ||||
|         message = await channel.get_message(payload.message_id) | ||||
|         if message.guild and message.channel.permissions_for(message.guild.get_member(client.user.id)).manage_messages: | ||||
|             await message.remove_reaction(payload.emoji, user) | ||||
|         await user.send(embed=card) | ||||
|     except discord.Forbidden: | ||||
|         # User doesn't have DMs enabled, not much we can do about that | ||||
|         pass | ||||
|         pass | ||||
|   | ||||
		Reference in New Issue
	
	Block a user