From 45a211832dc4555f519709f50bccaeffd438908f Mon Sep 17 00:00:00 2001 From: ZRunner Date: Sat, 21 Oct 2023 20:22:56 -0400 Subject: [PATCH] feat(gaw): add participants list embed color --- src/modules/giveaways/main.py | 2 +- src/modules/giveaways/views.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/giveaways/main.py b/src/modules/giveaways/main.py index 148b3fb..c31f1f4 100644 --- a/src/modules/giveaways/main.py +++ b/src/modules/giveaways/main.py @@ -281,7 +281,7 @@ async def gw_list_participants(self, interaction: COInteraction, giveaway: str): if not participants: await interaction.followup.send("No participants!") return - view = ParticipantsPaginator(self.bot, interaction.user, gaw, participants) + view = ParticipantsPaginator(self.bot, self.embed_color, interaction.user, gaw, participants) await view.send_init(interaction) @gw_list_participants.autocomplete("giveaway") diff --git a/src/modules/giveaways/views.py b/src/modules/giveaways/views.py index 6194fbf..befb6a4 100644 --- a/src/modules/giveaways/views.py +++ b/src/modules/giveaways/views.py @@ -26,8 +26,9 @@ def __init__(self, bot: CObot, data: GiveawayToSendData, button_label: str): class ParticipantsPaginator(Paginator): "Allows users to see the participants of a giveaway" - def __init__(self, client: CObot, user: Union[User, Member], gaw: GiveawayData, participants: list[int]): + def __init__(self, client: CObot, embed_color: int, user: Union[User, Member], gaw: GiveawayData, participants: list[int]): super().__init__(client, user) + self.embed_color = embed_color self.title = f"Participants of {gaw['name']}" self.participants = participants self.page_count = ceil(len(participants) / 20) @@ -45,13 +46,16 @@ async def get_page_content(self, interaction, page): f"<@{user_id}> ({user_id})" for user_id in self.participants[lower_index:upper_index] ] - if participants_count <= 20: - desc_header = f"### {participants_count} participants\n\n" + if participants_count == 1: + desc_header = "### 1 participant" + elif participants_count <= 20: + desc_header = f"### {participants_count} participants" else: - desc_header = f"### Participants {lower_index+1}-{upper_index} out of {participants_count}\n\n" + desc_header = f"### Participants {lower_index+1}-{upper_index} out of {participants_count}" embed = Embed( title=self.title, - description=desc_header + "\n".join(page_participants), + description=desc_header + "\n\n" + "\n".join(page_participants), + color=self.embed_color ) embed.set_footer(text=f"Page {page}/{self.page_count}") return {"embed": embed}