Skip to content

Commit

Permalink
Remove display_message and force a timeout msg
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 committed Dec 13, 2023
1 parent 47f9404 commit ffec9a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
8 changes: 6 additions & 2 deletions bot/libs/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
is_manager as is_manager,
is_mod as is_mod,
)
from .context import RoboContext as RoboContext
from .embeds import Embed as Embed, ErrorEmbed as ErrorEmbed
from .context import GuildContext as GuildContext, RoboContext as RoboContext
from .embeds import (
Embed as Embed,
ErrorEmbed as ErrorEmbed,
LoggingEmbed as LoggingEmbed,
)
from .errors import send_error_embed as send_error_embed
from .logger import RodhajLogger as RodhajLogger
from .modals import RoboModal as RoboModal
Expand Down
6 changes: 5 additions & 1 deletion bot/libs/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class ConfirmationView(RoboView):
def __init__(self, ctx, timeout: float, delete_after: bool):
super().__init__(ctx=ctx, display_message=False, timeout=timeout)
super().__init__(ctx=ctx, timeout=timeout)
self.value: Optional[bool] = None
self.delete_after = delete_after
self.message: Optional[discord.Message] = None
Expand Down Expand Up @@ -69,3 +69,7 @@ async def prompt(
view.message = await self.send(message, view=view, ephemeral=delete_after)
await view.wait()
return view.value


class GuildContext(RoboContext):
guild: discord.Guild
17 changes: 5 additions & 12 deletions bot/libs/utils/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
class RoboView(discord.ui.View):
"""Subclassed `discord.ui.View` that includes sane default configs"""

def __init__(self, ctx: RoboContext, display_message: bool = True, *args, **kwargs):
def __init__(self, ctx: RoboContext, *args, **kwargs):
super().__init__(*args, **kwargs)
self.ctx = ctx
self.display_message = display_message
self.message: Optional[discord.Message]

async def interaction_check(self, interaction: discord.Interaction, /) -> bool:
Expand All @@ -46,13 +45,7 @@ async def on_error(
async def on_timeout(self) -> None:
# This is the only way you can really edit the original message
if self.message:
if self.display_message:
embed = ErrorEmbed()
embed.title = "\U00002757 Timed Out"
embed.description = (
"Timed out waiting for a response. Cancelling action..."
)
await self.message.edit(embed=embed, view=None)
return

await self.message.edit(view=None)
embed = ErrorEmbed()
embed.title = "\U00002757 Timed Out"
embed.description = "Timed out waiting for a response. Cancelling action..."
await self.message.edit(embed=embed, view=None)

0 comments on commit ffec9a3

Please sign in to comment.