rewrite: New Rolemenu system. (Incomplete)
This commit is contained in:
@@ -10,6 +10,7 @@ from .micros import *
|
||||
from .pagers import *
|
||||
from .transformed import *
|
||||
from .config import *
|
||||
from .msgeditor import *
|
||||
|
||||
|
||||
# def create_task_in(coro, context: Context):
|
||||
|
||||
@@ -8,9 +8,10 @@ import discord
|
||||
from discord.ui import Modal, View, Item
|
||||
|
||||
from meta.logger import log_action_stack, logging_context
|
||||
from meta.errors import SafeCancellation
|
||||
|
||||
from . import logger
|
||||
from ..lib import MessageArgs
|
||||
from ..lib import MessageArgs, error_embed
|
||||
|
||||
__all__ = (
|
||||
'LeoUI',
|
||||
@@ -198,6 +199,25 @@ class LeoUI(View):
|
||||
"""
|
||||
try:
|
||||
raise error
|
||||
except SafeCancellation as e:
|
||||
if e.msg and not interaction.is_expired():
|
||||
try:
|
||||
if interaction.response.is_done():
|
||||
await interaction.followup.send(
|
||||
embed=error_embed(e.msg),
|
||||
ephemeral=True
|
||||
)
|
||||
else:
|
||||
await interaction.response.send_message(
|
||||
embed=error_embed(e.msg),
|
||||
ephemeral=True
|
||||
)
|
||||
except discord.HTTPException:
|
||||
pass
|
||||
logger.debug(
|
||||
f"Caught a safe cancellation from LeoUI: {e.details}",
|
||||
extra={'action': 'Cancel'}
|
||||
)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
f"Unhandled interaction exception occurred in item {item!r} of LeoUI {self!r}",
|
||||
|
||||
@@ -160,6 +160,7 @@ class ModalRetryUI(LeoUI):
|
||||
@property
|
||||
def embed(self):
|
||||
return discord.Embed(
|
||||
title="Uh-Oh!",
|
||||
description=self.message,
|
||||
colour=discord.Colour.red()
|
||||
)
|
||||
|
||||
1022
src/utils/ui/msgeditor.py
Normal file
1022
src/utils/ui/msgeditor.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user