From 5c05a8a262784edeb2d93947e9405de3e8cc3f10 Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Sat, 17 Dec 2022 23:14:11 -0500 Subject: [PATCH] Add reply upload functionality --- src/memes.py | 10 ++++++++-- src/on_message.py | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/memes.py b/src/memes.py index d7d0ba3..5a4fb2e 100644 --- a/src/memes.py +++ b/src/memes.py @@ -210,6 +210,7 @@ def nameBuilder(command): return uploaded_file_name + ############################################################################### # Calldict methods @@ -280,7 +281,7 @@ async def memeDump(command, message, client): return "Enjoy your memes :)" # get an uploaded meme and save it -async def uploadMeme(command, message, client): +async def uploadMeme(command, message, discordClient): global memes_to_md5 uploader_tags = Tags.new_object_tags() @@ -291,7 +292,12 @@ async def uploadMeme(command, message, client): file_names = [] if len(message.attachments) <= 0: - return "You didn't attach anything! Please attach a file to upload" + if message.reference is not None: # this is a reply upload + m = await message.channel.fetch_message(message.reference.message_id) + result = await uploadMeme(command, m, client) + return result + else: + return "You didn't attach anything! Please attach a file to upload" #TODO left off on adding logic to diff --git a/src/on_message.py b/src/on_message.py index ca45243..debcfae 100644 --- a/src/on_message.py +++ b/src/on_message.py @@ -16,6 +16,10 @@ async def showHelp(very, useless, arguments): str += " Get all memes that are like the given query\n" str += "!help\n" str += " Print this message\n" + str += "!up [NAME]\n" + str += " Upload a meme. If NAME is provided it will be named as such.\n" + str += " You need to either attach the meme with the message, or reply to a\n" + str += " message with the meme you want to upload\n" str += "```" return str