Skip to content

Commit

Permalink
added error handling to views
Browse files Browse the repository at this point in the history
  • Loading branch information
FirePlank committed Nov 30, 2023
1 parent 517dd27 commit b92ce53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion bot/extensions/adventofcode/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import re
from datetime import datetime
from typing import Any
from zoneinfo import ZoneInfo

import discord
from bs4 import BeautifulSoup
from discord import ui
from discord import Interaction, ui
from discord.ui import Item

from bot import core
from bot.extensions.adventofcode.utils import LEADERBOARD_ID, YEAR, Member, fetch_leaderboard, home_embed, ordinal
Expand Down Expand Up @@ -109,3 +111,6 @@ async def global_leaderboard(self, interaction: core.InteractionType, _button: u
embed.description = s_desc

await interaction.response.edit_message(embed=embed, view=self)

async def on_error(self, interaction: Interaction, _error: Exception, _item: Item[Any], /) -> None:
await interaction.client.on_error("adventofcode_view")
5 changes: 4 additions & 1 deletion bot/extensions/polls/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import typing as t

import discord
from discord import ui
from discord import Interaction, ui

from bot import core
from bot.extensions.polls.utils import emojis
Expand Down Expand Up @@ -118,3 +118,6 @@ async def create_poll(self, interaction: core.InteractionType, _button: ui.Butto

for i in range(0, len(embed.fields)):
await message.add_reaction(emojis[i])

async def on_error(self, interaction: Interaction, _error: Exception, _item: ui.Item[t.Any], /) -> None:
await interaction.client.on_error("poll_view")

0 comments on commit b92ce53

Please sign in to comment.