from loguru import logger
import nonebot
from nonebot.adapters import Event as BaseEvent
from nonebot.adapters.discord.event import MessageEvent as DiscordMessageEvent
from nonebot_plugin_alconna import (
    UniMessage,
    UniMsg
)
from konabot.plugins.notice_ui.notice import NoticeUI
from nonebot_plugin_alconna import on_alconna, Alconna, Args

evt = on_alconna(Alconna(
    "notice",
    Args["title", str],
    Args["message", str]
    ),
    use_cmd_start=True, use_cmd_sep=False, skip_for_unmatch=True
)

@evt.handle()
async def _(title: str, message: str, msg: UniMsg, event: BaseEvent):
    logger.debug(f"Received notice command with title: {title}, message: {message}")

    out = await NoticeUI.render_notice(title, message)

    await evt.send(await UniMessage().image(raw=out).export())