Closed MrNesli closed 1 year ago
Oops I messed up a little with commits
Omg, I did fucky wacky again :)
I decided to write you an example on how to do a countdown that changes the message at the end of the countdown. This will be an modified version of the PagedEmbed
view and to make this easier to read, I will only include the new code and old code will be represented by ...
.
class PagedEmbedView(View):
def __init__(self, embeds: List[Embed], seconds: int = 30):
...
self._seconds = seconds
...
async def send(self, ctx: Context, ephemeral: bool = True):
self.__message = await ctx.send(embed=self.__embeds.current, view=self, ephemeral=ephemeral)
asyncio.create_task(self.__countdown_task())
async def refresh(self):
await self.__message.edit(embed=self.__embeds.current, view=self)
async def __countdown_task(self):
while self._seconds > 0:
self.__embeds.current.set_footer(text=f"Time left: {self._seconds}")
await self.refresh()
self._seconds -= 1
await asyncio.sleep(1)
await self.__countdown_callback()
async def __countdown_callback(self):
self.__embeds.current.title = "Time's up!"
self.__embeds.current.set_footer(text="")
self.clear_items()
await self.refresh()
This is what it looks like
Voting System #40
Command:
/poll create title=<poll title> options_count=<number of poll options> poll_time=<poll duration>
Possible improvements: