Update proxy.py

Adding code to remove question mark reaction after sending the message card
This commit is contained in:
Grey Himmel 2019-04-22 17:21:44 -04:00 committed by GitHub
parent 3d913018d0
commit 10113d331e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -233,15 +233,15 @@ 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: 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)
card = await embeds.message_card(client, msg)
user = client.get_user(payload.user_id)
if not user:
# We couldn't find this user in the cache - bail
return False
@ -249,6 +249,9 @@ async def do_query_message(conn, client: discord.Client, queryer_id: int, messag
# Send the card to the user
try:
await user.send(embed=card)
message = await client.fetch_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)
except discord.Forbidden:
# User doesn't have DMs enabled, not much we can do about that
pass
pass