aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/info/help.py16
-rw-r--r--bot/exts/info/subscribe.py10
2 files changed, 11 insertions, 15 deletions
diff --git a/bot/exts/info/help.py b/bot/exts/info/help.py
index 29d73c564..597534083 100644
--- a/bot/exts/info/help.py
+++ b/bot/exts/info/help.py
@@ -6,7 +6,7 @@ from collections import namedtuple
from contextlib import suppress
from typing import List, Optional, Union
-from disnake import ButtonStyle, Colour, Embed, Emoji, Interaction, PartialEmoji, ui
+from disnake import ButtonStyle, Colour, Embed, Emoji, HTTPException, Interaction, PartialEmoji, ui
from disnake.ext.commands import Bot, Cog, Command, CommandError, Context, DisabledCommand, Group, HelpCommand
from rapidfuzz import fuzz, process
from rapidfuzz.utils import default_process
@@ -57,16 +57,13 @@ class SubcommandButton(ui.Button):
async def callback(self, interaction: Interaction) -> None:
"""Edits the help embed to that of the subcommand."""
- message = interaction.message
- if not message:
- return
-
subcommand = self.command
if isinstance(subcommand, Group):
embed, subcommand_view = await self.help_command.format_group_help(subcommand)
else:
embed, subcommand_view = await self.help_command.command_formatting(subcommand)
- await message.edit(embed=embed, view=subcommand_view)
+ with suppress(HTTPException):
+ await interaction.response.edit_message(embed=embed, view=subcommand_view)
class GroupButton(ui.Button):
@@ -98,12 +95,9 @@ class GroupButton(ui.Button):
async def callback(self, interaction: Interaction) -> None:
"""Edits the help embed to that of the parent."""
- message = interaction.message
- if not message:
- return
-
embed, group_view = await self.help_command.format_group_help(self.command.parent)
- await message.edit(embed=embed, view=group_view)
+ with suppress(HTTPException):
+ await interaction.response.edit_message(embed=embed, view=group_view)
class CommandView(ui.View):
diff --git a/bot/exts/info/subscribe.py b/bot/exts/info/subscribe.py
index 0f285e0cb..ddfb238b8 100644
--- a/bot/exts/info/subscribe.py
+++ b/bot/exts/info/subscribe.py
@@ -1,4 +1,5 @@
import calendar
+import contextlib
import operator
import typing as t
from dataclasses import dataclass
@@ -82,7 +83,7 @@ class SingleRoleButton(disnake.ui.Button):
ADD_STYLE = disnake.ButtonStyle.success
REMOVE_STYLE = disnake.ButtonStyle.red
UNAVAILABLE_STYLE = disnake.ButtonStyle.secondary
- LABEL_FORMAT = "{action} role {role_name}."
+ LABEL_FORMAT = "{action} role {role_name}"
CUSTOM_ID_FORMAT = "subscribe-{role_id}"
def __init__(self, role: AssignableRole, assigned: bool, row: int):
@@ -106,7 +107,8 @@ class SingleRoleButton(disnake.ui.Button):
"""Update the member's role and change button text to reflect current text."""
if isinstance(interaction.user, disnake.User):
log.trace("User %s is not a member", interaction.user)
- await interaction.message.delete()
+ with contextlib.suppress(disnake.HTTPException):
+ await interaction.delete_original_message()
self.view.stop()
return
@@ -132,8 +134,8 @@ class SingleRoleButton(disnake.ui.Button):
self.style = self.REMOVE_STYLE if self.assigned else self.ADD_STYLE
self.label = self.LABEL_FORMAT.format(action="Remove" if self.assigned else "Add", role_name=self.role.name)
try:
- await interaction.message.edit(view=self.view)
- except disnake.NotFound:
+ await interaction.response.edit_message(view=self.view)
+ except disnake.HTTPException:
log.debug("Subscribe message for %s removed before buttons could be updated", interaction.user)
self.view.stop()