From 2c82b226a300370b78dbb03d7716ac9611d4dbe9 Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Thu, 9 Feb 2023 14:20:44 -0500 Subject: [PATCH] Add custom IDs for buttons --- cogs/prompt_optimizer_cog.py | 4 ++-- services/image_service.py | 6 +++--- services/moderations_service.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cogs/prompt_optimizer_cog.py b/cogs/prompt_optimizer_cog.py index 1eaafae..28e1613 100644 --- a/cogs/prompt_optimizer_cog.py +++ b/cogs/prompt_optimizer_cog.py @@ -182,7 +182,7 @@ class DrawButton(discord.ui.Button["OptimizeView"]): def __init__( self, converser_cog, image_service_cog, deletion_queue, custom_api_key ): - super().__init__(style=discord.ButtonStyle.green, label="Draw") + super().__init__(style=discord.ButtonStyle.green, label="Draw", custom_id="draw_button_optimizer") self.converser_cog = converser_cog self.image_service_cog = image_service_cog self.deletion_queue = deletion_queue @@ -237,7 +237,7 @@ class RedoButton(discord.ui.Button["OptimizeView"]): def __init__( self, converser_cog, image_service_cog, deletion_queue, custom_api_key=None ): - super().__init__(style=discord.ButtonStyle.danger, label="Retry") + super().__init__(style=discord.ButtonStyle.danger, label="Retry", custom_id="redo_button_optimizer") self.converser_cog = converser_cog self.image_service_cog = image_service_cog self.deletion_queue = deletion_queue diff --git a/services/image_service.py b/services/image_service.py index 662446b..66effb8 100644 --- a/services/image_service.py +++ b/services/image_service.py @@ -262,7 +262,7 @@ class SaveView(discord.ui.View): class VaryButton(discord.ui.Button): def __init__(self, number, image_url, cog, converser_cog, custom_api_key): - super().__init__(style=discord.ButtonStyle.blurple, label="Vary " + str(number)) + super().__init__(style=discord.ButtonStyle.blurple, label="Vary " + str(number), custom_id="vary_button") self.number = number self.image_url = image_url self.cog = cog @@ -318,7 +318,7 @@ class VaryButton(discord.ui.Button): class SaveButton(discord.ui.Button["SaveView"]): def __init__(self, number: int, image_url: str): - super().__init__(style=discord.ButtonStyle.gray, label="Save " + str(number)) + super().__init__(style=discord.ButtonStyle.gray, label="Save " + str(number), custom_id="save_button") self.number = number self.image_url = image_url @@ -349,7 +349,7 @@ class SaveButton(discord.ui.Button["SaveView"]): class RedoButton(discord.ui.Button["SaveView"]): def __init__(self, cog, converser_cog, custom_api_key): - super().__init__(style=discord.ButtonStyle.danger, label="Retry") + super().__init__(style=discord.ButtonStyle.danger, label="Retry", custom_id="redo_button_draw_main") self.cog = cog self.converser_cog = converser_cog self.custom_api_key = custom_api_key diff --git a/services/moderations_service.py b/services/moderations_service.py index 9df6ba7..c07dbbf 100644 --- a/services/moderations_service.py +++ b/services/moderations_service.py @@ -323,7 +323,7 @@ class ModerationAdminView(discord.ui.View): class ApproveMessageButton(discord.ui.Button["ModerationAdminView"]): def __init__(self, message, moderation_message, current_num): - super().__init__(style=discord.ButtonStyle.green, label="Approve") + super().__init__(style=discord.ButtonStyle.green, label="Approve", custom_id="approve_button") self.message = message self.moderation_message = moderation_message self.current_num = current_num @@ -336,7 +336,7 @@ class ApproveMessageButton(discord.ui.Button["ModerationAdminView"]): class DeleteMessageButton(discord.ui.Button["ModerationAdminView"]): def __init__(self, message, moderation_message, current_num): - super().__init__(style=discord.ButtonStyle.danger, label="Delete Message") + super().__init__(style=discord.ButtonStyle.danger, label="Delete Message", custom_id="delete_button") self.message = message self.moderation_message = moderation_message self.current_num = current_num @@ -361,7 +361,7 @@ class DeleteMessageButton(discord.ui.Button["ModerationAdminView"]): class KickUserButton(discord.ui.Button["ModerationAdminView"]): def __init__(self, message, moderation_message, current_num): - super().__init__(style=discord.ButtonStyle.danger, label="Kick User") + super().__init__(style=discord.ButtonStyle.danger, label="Kick User", custom_id="kick_button") self.message = message self.moderation_message = moderation_message self.current_num = current_num @@ -400,7 +400,7 @@ class TimeoutUserButton(discord.ui.Button["ModerationAdminView"]): def __init__( self, message, moderation_message, current_num, hours, nodelete, source_deleted ): - super().__init__(style=discord.ButtonStyle.danger, label=f"Timeout {hours}h") + super().__init__(style=discord.ButtonStyle.danger, label=f"Timeout {hours}h", custom_id="timeout_button") self.message = message self.moderation_message = moderation_message self.hours = hours