Something went wrong. Try again.
@ the bot in a reply to quote a message. aesth.lol/quote
Something went wrong. Try again.
QuoteThisMessage main.py
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115""" 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 <https://www.gnu.org/licenses/>."""
import discordfrom discord.ext import commands
from pilmoji import Pilmojifrom PIL import Image, ImageDraw, ImageFont
import textwrap
import dotenvdotenv.load_dotenv()
import osfrom 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.eventasync 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.eventasync 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)