""" Quote This Message Copyright (C) 2026 Aesthetic (me@aesth.lol) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ import discord from discord.ext import commands from pilmoji import Pilmoji from PIL import Image, ImageDraw, ImageFont import textwrap import dotenv dotenv.load_dotenv() import os from io import BytesIO intents = discord.Intents.default() intents.message_content = True quote_font = ImageFont.truetype(os.path.expanduser(os.environ.get("FONT_PATH")), size=125) author_font = ImageFont.truetype(os.path.expanduser(os.environ.get("FONT_PATH")), size=90) credit_font = ImageFont.truetype(os.path.expanduser(os.environ.get("FONT_PATH")), size=50) bot = commands.Bot("", intents=intents) @bot.event async def on_ready(): print(f'logged in: {bot.user}') await bot.tree.sync() print("synced commands") # todo: cogs? async def _quote_msg(message: discord.Message): quote = message.content author = message.author.display_name username = str(message.author) try: avatar = Image.open(BytesIO(await message.author.display_avatar.read())) avatar = avatar.resize((250,250)) except Exception: avatar = Image.new("RGBA", (0,0)) image = Image.new("RGBA", (1890, 1063), (0,0,0)) draw = ImageDraw.Draw(image) with Pilmoji(image=image) as emoji: wrapped = textwrap.fill(quote, 27) emoji.text((90, 1063/2-550/2), wrapped, font=quote_font, emoji_position_offset=(5, -30)) draw.text((90, 1063-150), f"- {username}", font=author_font) credit = "Made with QuoteThisMessage: aesth.lol/quote" draw.text((1860-draw.textlength(credit, font=credit_font), 50), credit, font=credit_font) image.paste(avatar) file = BytesIO() image.save(file, format="PNG") file.seek(0) # clean up image.close() avatar.close() return file @bot.tree.context_menu(name="Quote this message") @discord.app_commands.allowed_contexts(True, True, True) async def quote_message(interaction: discord.Interaction, message: discord.Message): file = await _quote_msg(message) file = discord.File(file, "quote.png") await interaction.response.send_message(file=file) @bot.event async def on_message(message: discord.Message): if bot.user in message.mentions: if message.reference and message.type == discord.MessageType.reply: reference = message.reference if not reference.resolved: await message.reply("Discord error. This isn't a bug with the bot!") return print(type(message.reference)) if type(message.reference) == discord.message.DeletedReferencedMessage: await message.reply("The message was deleted.") return msg = await message.reply(content="Generating...") file = await _quote_msg(message.reference.resolved) file = discord.File(file, "quote.png") await message.reply(file=file) await msg.delete() else: await message.reply("Oops! You didn't reply to a message when you pinged the bot...") token = os.environ.get("DISCORD_TOKEN") print("Quote This Message: aesth.lol/quote") bot.run(token)