GoldyBot.utility.views.confirm
1import GoldyBot 2 3async def yes_or_no(ctx:GoldyBot.InteractionToCtx, names:tuple=("Yes", "No!"), auto_delete:bool=True): 4 """ 5 Goldy Bot's yes or no button view. (Only the command author can interact with this!) 6 """ 7 8 class yes_or_no_button_view(GoldyBot.nextcord.ui.View): 9 def __init__(self, author:GoldyBot.Member): 10 super().__init__() 11 self.value = None 12 self.response_message:GoldyBot.nextcord.PartialInteractionMessage = None 13 14 self.author = author 15 16 @GoldyBot.nextcord.ui.button(label=names[0], style=GoldyBot.nextcord.ButtonStyle.green) 17 async def yes(self, button: GoldyBot.nextcord.ui.Button, interaction: GoldyBot.nextcord.Interaction): 18 if self.author.member.id == interaction.user.id: 19 self.response_message = await interaction.response.send_message("**Okay! 💛**", ephemeral=True) 20 self.value = True 21 self.stop() 22 23 @GoldyBot.nextcord.ui.button(label=names[1], style=GoldyBot.nextcord.ButtonStyle.red) 24 async def no(self, button: GoldyBot.nextcord.ui.Button, interaction: GoldyBot.nextcord.Interaction): 25 if self.author.member.id == interaction.user.id: 26 self.response_message = await interaction.response.send_message("**Alright, cancelled! 💚**", ephemeral=True) 27 self.value = False 28 self.stop() 29 30 return yes_or_no_button_view(GoldyBot.Member(ctx))
async def
yes_or_no( ctx: GoldyBot.objects.slash.InteractionToCtx, names: tuple = ('Yes', 'No!'), auto_delete: bool = True):
4async def yes_or_no(ctx:GoldyBot.InteractionToCtx, names:tuple=("Yes", "No!"), auto_delete:bool=True): 5 """ 6 Goldy Bot's yes or no button view. (Only the command author can interact with this!) 7 """ 8 9 class yes_or_no_button_view(GoldyBot.nextcord.ui.View): 10 def __init__(self, author:GoldyBot.Member): 11 super().__init__() 12 self.value = None 13 self.response_message:GoldyBot.nextcord.PartialInteractionMessage = None 14 15 self.author = author 16 17 @GoldyBot.nextcord.ui.button(label=names[0], style=GoldyBot.nextcord.ButtonStyle.green) 18 async def yes(self, button: GoldyBot.nextcord.ui.Button, interaction: GoldyBot.nextcord.Interaction): 19 if self.author.member.id == interaction.user.id: 20 self.response_message = await interaction.response.send_message("**Okay! 💛**", ephemeral=True) 21 self.value = True 22 self.stop() 23 24 @GoldyBot.nextcord.ui.button(label=names[1], style=GoldyBot.nextcord.ButtonStyle.red) 25 async def no(self, button: GoldyBot.nextcord.ui.Button, interaction: GoldyBot.nextcord.Interaction): 26 if self.author.member.id == interaction.user.id: 27 self.response_message = await interaction.response.send_message("**Alright, cancelled! 💚**", ephemeral=True) 28 self.value = False 29 self.stop() 30 31 return yes_or_no_button_view(GoldyBot.Member(ctx))
Goldy Bot's yes or no button view. (Only the command author can interact with this!)