Skip to content

Commit

Permalink
Merge pull request #333 from being24/develop
Browse files Browse the repository at this point in the history
Refactor polling cog and fix delete_after bug
  • Loading branch information
being24 authored Jan 30, 2024
2 parents 83503e0 + d432a99 commit c3bf995
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cogs/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .utils.polling_manager import PollingManager, PollingParameter
from .utils.setting_manager import SettingManager

c = CommonUtil()
logger = logging.getLogger("discord")
polling_mng = PollingManager()

Expand All @@ -29,7 +30,6 @@ def __init__(self):
super().__init__(
placeholder="対象を選択してください", min_values=0, max_values=25
)
# self.aggregation_mng = AggregationManager()

async def callback(self, interaction: discord.Interaction):
if self.view is None:
Expand All @@ -39,6 +39,9 @@ async def callback(self, interaction: discord.Interaction):
item.disabled = True
await self.view.message.edit(view=self.view)

if isinstance(interaction.message, discord.Message):
await c.delete_after(interaction.message)

now = discord.utils.utcnow()
poll_time_stamp = f"<t:{int(now.timestamp())}:f>"

Expand Down Expand Up @@ -91,6 +94,7 @@ async def on_timeout(self):
try:
await self.message.edit(view=self) # type: ignore
except discord.NotFound:
print("not found")
pass

async def interaction_check(self, interaction: discord.Interaction) -> bool:
Expand Down Expand Up @@ -126,7 +130,6 @@ class Polling(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.setting_mng = SettingManager()
self.c = CommonUtil()

self.o = "\N{HEAVY LARGE CIRCLE}"
self.x = "\N{CROSS MARK}"
Expand All @@ -153,15 +156,15 @@ async def poll(
interaction: discord.Interaction,
question: str,
option_1: str,
option_2: str = None,
option_3: str = None,
option_4: str = None,
option_5: str = None,
option_6: str = None,
option_7: str = None,
option_8: str = None,
option_9: str = None,
option_10: str = None,
option_2: str | None = None,
option_3: str | None = None,
option_4: str | None = None,
option_5: str | None = None,
option_6: str | None = None,
option_7: str | None = None,
option_8: str | None = None,
option_9: str | None = None,
option_10: str | None = None,
) -> None:
"""optionで選択肢を追加します.ロールは最後に選択してください."""

Expand Down

0 comments on commit c3bf995

Please sign in to comment.