diff options
author | 2022-03-05 23:11:17 +0000 | |
---|---|---|
committer | 2022-03-15 10:16:13 +0000 | |
commit | 4fcca02e5dee769c1ad4b679238717cc1a471940 (patch) | |
tree | 749b60a48d4f9f8276faf23390a36097605e4aee | |
parent | Merge pull request #2114 from python-discord/jb3/increase-watch-limit (diff) |
Revert "No longer use Interaction.message, as it was removed from disnake"
This reverts commit a1c73b5eca88d1b92cd42d3c41183387209461b9.
-rw-r--r-- | bot/exts/info/help.py | 16 | ||||
-rw-r--r-- | bot/exts/info/subscribe.py | 10 |
2 files changed, 15 insertions, 11 deletions
diff --git a/bot/exts/info/help.py b/bot/exts/info/help.py index 597534083..29d73c564 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, HTTPException, Interaction, PartialEmoji, ui +from disnake import ButtonStyle, Colour, Embed, Emoji, 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,13 +57,16 @@ 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) - with suppress(HTTPException): - await interaction.response.edit_message(embed=embed, view=subcommand_view) + await message.edit(embed=embed, view=subcommand_view) class GroupButton(ui.Button): @@ -95,9 +98,12 @@ 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) - with suppress(HTTPException): - await interaction.response.edit_message(embed=embed, view=group_view) + await message.edit(embed=embed, view=group_view) class CommandView(ui.View): diff --git a/bot/exts/info/subscribe.py b/bot/exts/info/subscribe.py index ddfb238b8..0f285e0cb 100644 --- a/bot/exts/info/subscribe.py +++ b/bot/exts/info/subscribe.py @@ -1,5 +1,4 @@ import calendar -import contextlib import operator import typing as t from dataclasses import dataclass @@ -83,7 +82,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): @@ -107,8 +106,7 @@ 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) - with contextlib.suppress(disnake.HTTPException): - await interaction.delete_original_message() + await interaction.message.delete() self.view.stop() return @@ -134,8 +132,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.response.edit_message(view=self.view) - except disnake.HTTPException: + await interaction.message.edit(view=self.view) + except disnake.NotFound: log.debug("Subscribe message for %s removed before buttons could be updated", interaction.user) self.view.stop() |