From 4208bffb8c473345c77a8ddd29405d87aa823341 Mon Sep 17 00:00:00 2001 From: Matthew Cohen Date: Sun, 23 Jun 2024 03:59:16 -0400 Subject: [PATCH] Full command test pass testing --- modules/social.py | 13 ++++++------- modules/statistics.py | 18 +++++++----------- modules/utility.py | 9 +-------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/modules/social.py b/modules/social.py index 25b4d33..326eb50 100644 --- a/modules/social.py +++ b/modules/social.py @@ -1003,7 +1003,7 @@ async def return_failure(interaction: discord.Interaction, game_name: str): await msg.delete() await interaction.followup.send( - message_reply, file=await self._generate_profile_card_from_member(interaction.user) + message_reply, file=await self._generate_profile_card_from_member(interaction.user), ephemeral=True ) class BackgroundSelectMenu(discord.ui.View): @@ -1053,7 +1053,6 @@ async def select_option(self, interaction: discord.Interaction): f'{config.greenTick} Your background has been successfully updated on your profile card! Here\'s how it looks:', file=await self.Parent._generate_profile_card_from_member(interaction.user), embed=None, - view=None, ephemeral=True, ) self.stop() @@ -1064,14 +1063,14 @@ async def select_option(self, interaction: discord.Interaction): async def cancel_button(self, interaction: discord.Interaction): await interaction.response.edit_message( - content='Background editing canceled. To begin again, rerun the command', embed=None, view=None + content='Background editing canceled. To begin again, rerun the command', attachments=[], embed=None, view=None ) self.stop() async def on_timeout(self): - if self.message: + if self.message and not self.is_finished(): await self.message.edit( - content='Background editing timed out. To begin again, rerun the command', embed=None, view=None + content='Background editing timed out. To begin again, rerun the command', attachments=[], embed=None, view=None ) @social_group.command(name='background', description='Update the background you use on your profile card') @@ -1247,7 +1246,7 @@ async def _trivia_award(self, interaction, members: str): await interaction.response.send_message(f'{config.loading} Processing awards to {len(members)} member(s)...') for m in members: try: - user = int(user) + user = int(m) m = interaction.guild.get_member(user) if not m: try: @@ -1297,7 +1296,7 @@ async def _trivia_reduce(self, interaction: discord.Interaction, members: str): await interaction.response.send_message(f'{config.loading} Reducing awards from {len(members)} member(s)...') for m in members: try: - user = int(user) + user = int(m) m = interaction.guild.get_member(user) if not m: try: diff --git a/modules/statistics.py b/modules/statistics.py index 9f6d15a..6b104af 100644 --- a/modules/statistics.py +++ b/modules/statistics.py @@ -151,7 +151,7 @@ async def _stats_server( dayStr = ( 'In the last 30 days' - if not start + if not start and not end else 'Between ' + searchDate.strftime('%Y-%m-%d') + ' and ' + endDate.strftime('%Y-%m-%d') ) netMembers = netJoins - netLeaves @@ -216,24 +216,20 @@ async def _stats_roles( await interaction.response.send_message('One moment, crunching the numbers...') if role: lines = [] - desc = f'There are currently **{len(role.members)}** users with the **{role.name}** role:\n\n' + desc = f'There are currently **{len(role.members)}** members with the **{role.name}** role:\n\n' for member in role.members: lines.append(f'* {member} ({member.id})') title = f'{interaction.guild.name} Role Statistics' fields = tools.convert_list_to_fields(lines) - await interaction.delete_original_response() - # TODO: embed pagination need to be converted to UI Kit - return await tools.send_paginated_embed( - self.bot, - interaction.channel, - fields, - owner=interaction.user, + view = tools.PaginatedEmbed( + interaction=interaction, + fields=fields, title=title, description=desc, - color=0xD267BA, - page_character_limit=3000, + color=0xD267BA ) + return await interaction.edit_original_response(content='Here is the requested list of members with that role:', view=view) else: roleCounts = [] diff --git a/modules/utility.py b/modules/utility.py index fecf38a..43e74af 100644 --- a/modules/utility.py +++ b/modules/utility.py @@ -295,14 +295,7 @@ def message_filter(message): # Message may not exist pass - if count >= 100: - # Original interaction deleted - m = await interaction.channel.send(f'{config.greenTick} Clean action complete') - - else: - # Original interaction still available, need to use followup - m = await interaction.followup.send(f'{config.greenTick} Clean action complete', wait=True) - + m = await interaction.channel.send(f'{config.greenTick} Clean action complete') return await m.delete(delay=5) @app_commands.guilds(discord.Object(id=config.nintendoswitch))