-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: separate views, add timeout prevention and fix bug in song titl…
…e matching (#160)
- Loading branch information
Showing
4 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
### | ||
# Copyright (c) 2024 NiceAesth. All rights reserved. | ||
### | ||
|
||
from __future__ import annotations | ||
|
||
import time | ||
from typing import TYPE_CHECKING | ||
|
||
import discord | ||
|
||
if TYPE_CHECKING: | ||
from classes.osudle import BaseOsudleGame | ||
|
||
|
||
class OsudleGuessView(discord.ui.View): | ||
def __init__(self, game: object) -> None: | ||
super().__init__(timeout=game.interaction_timeout) | ||
self.game: BaseOsudleGame = game | ||
|
||
@discord.ui.button(label="Skip", style=discord.ButtonStyle.danger) | ||
async def skip_button( | ||
self, | ||
interaction: discord.Interaction, | ||
button: discord.ui.Button, | ||
): | ||
await self.game.skip(interaction) | ||
|
||
|
||
class OsudleContinueView(discord.ui.View): | ||
def __init__(self, game) -> None: | ||
super().__init__(timeout=game.interaction_timeout) | ||
self.game = game | ||
|
||
@discord.ui.button(label="Continue", style=discord.ButtonStyle.primary) | ||
async def continue_button( | ||
self, | ||
interaction: discord.Interaction, | ||
button: discord.ui.Button, | ||
): | ||
await interaction.response.defer() | ||
self.game.last_interaction_time = time.monotonic() | ||
self.game.interaction = interaction | ||
self.stop() |