paper-dynasty-discord/utilities/pages.py
Cal Corum ee80cd72ae fix: apply Black formatting and resolve ruff lint violations
Run Black formatter across 83 files and fix 1514 ruff violations:
- E722: bare except → typed exceptions (17 fixes)
- E711/E712/E721: comparison style fixes with noqa for SQLAlchemy (44 fixes)
- F841: unused variable assignments (70 fixes)
- F541/F401: f-string and import cleanup (1383 auto-fixes)

Remaining 925 errors are all F403/F405 (star imports) — structural,
requires converting to explicit imports in a separate effort.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 11:37:46 -05:00

51 lines
1.6 KiB
Python

import discord
import logging
logger = logging.getLogger("discord_app")
class Pagination(discord.ui.View):
def __init__(self, responders: list, timeout: float = 300.0):
super().__init__(timeout=timeout)
if not isinstance(responders, list):
raise TypeError("responders must be a list")
self.value = None
self.responders = responders
@discord.ui.button(label="⏮️", style=discord.ButtonStyle.blurple)
async def left_button(
self, interaction: discord.Interaction, button: discord.ui.Button
):
if interaction.user not in self.responders:
logger.info(f"{interaction.user} is not in {self.responders}")
return
self.value = "left"
await interaction.response.defer()
self.stop()
@discord.ui.button(label="❌️", style=discord.ButtonStyle.secondary)
async def cancel_button(
self, interaction: discord.Interaction, button: discord.ui.Button
):
if interaction.user not in self.responders:
logger.info(f"{interaction.user} is not in {self.responders}")
return
self.value = "cancel"
await interaction.response.defer()
self.stop()
@discord.ui.button(label="⏭️", style=discord.ButtonStyle.blurple)
async def right_button(
self, interaction: discord.Interaction, button: discord.ui.Button
):
if interaction.user not in self.responders:
logger.info(f"{interaction.user} is not in {self.responders}")
return
self.value = "right"
await interaction.response.defer()
self.stop()