#Nothing gets printed on the terminal, and nothing gets sent. discord bot command not working

1 messages · Page 1 of 1 (latest)

broken swallow
#

hey, i have a bot command that for some reason doesnt work, nothing gets sent in the discord server and nothing is on the terminal, here is my code

import hikari
import lightbulb
import io
from PIL import Image, ImageDraw, ImageFont

plugin = lightbulb.Plugin('quote')

@plugin.listener(hikari.MessageCreateEvent)
async def on_message_create(event):
    message = event.message

    if message and message.content and message.content.startswith("@light fractal"):
        # Extract the referenced message ID from the content
        referenced_message_id = message.content.split()[-1]
        try:
            # Try to convert the ID to an integer and fetch the referenced message
            referenced_message_id = int(referenced_message_id)
            referenced_message = await event.bot.rest.fetch_message(event.channel_id, referenced_message_id)
            text = referenced_message.content

            # Generate an image with the text
            image = create_text_image(text)

            # Send the image as a response
            with io.BytesIO() as image_binary:
                image.save(image_binary, "PNG")
                image_binary.seek(0)
                await event.bot.rest.create_message(
                    event.channel_id, content=f"erm what the flip", file=hikari.File(fp=image_binary, filename="image.png")
                )
        except (ValueError, hikari.NotFoundError):
            pass

def create_text_image(text):
    image = Image.new("RGB", (400, 200), (255, 255, 255))
    draw = ImageDraw.Draw(image)
    font = ImageFont.load_default()
    draw.text((10, 10), text, fill=(0, 0, 0), font=font)
    return image

def load(bot):
    bot.add_plugin(plugin)
broken swallow
#

ill try