From 2eedaec2e3736a0495741ecb7bce062c1239201f Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 23 May 2024 17:51:05 +0100 Subject: [PATCH 1/3] Change sacrifice command embed colours to go green when successful from red --- src/buttonEvents/Sacrifice.ts | 4 ++-- src/commands/sacrifice.ts | 2 +- src/constants/EmbedColours.ts | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/buttonEvents/Sacrifice.ts b/src/buttonEvents/Sacrifice.ts index 6c4a1a6..5306764 100644 --- a/src/buttonEvents/Sacrifice.ts +++ b/src/buttonEvents/Sacrifice.ts @@ -67,7 +67,7 @@ export default class Sacrifice extends ButtonEvent { const embed = new EmbedBuilder() .setTitle("Card Sacrificed") .setDescription(description.join("\n")) - .setColor(EmbedColours.Ok) + .setColor(EmbedColours.Green) .setFooter({ text: `${interaction.user.username} · ${cardData.card.name}` }); const row = new ActionRowBuilder() @@ -122,7 +122,7 @@ export default class Sacrifice extends ButtonEvent { const embed = new EmbedBuilder() .setTitle("Sacrifice Cancelled") .setDescription(description.join("\n")) - .setColor(EmbedColours.Error) + .setColor(EmbedColours.Grey) .setFooter({ text: `${interaction.user.username} · ${cardData.card.name}` }); const row = new ActionRowBuilder() diff --git a/src/commands/sacrifice.ts b/src/commands/sacrifice.ts index c6dc7b3..0a72e4b 100644 --- a/src/commands/sacrifice.ts +++ b/src/commands/sacrifice.ts @@ -50,7 +50,7 @@ export default class Sacrifice extends Command { const embed = new EmbedBuilder() .setTitle("Sacrifice") .setDescription(description.join("\n")) - .setColor(EmbedColours.Grey) + .setColor(EmbedColours.Error) .setFooter({ text: `${interaction.user.username} · ${cardData.card.name}` }); const row = new ActionRowBuilder() diff --git a/src/constants/EmbedColours.ts b/src/constants/EmbedColours.ts index 36777e3..f270eef 100644 --- a/src/constants/EmbedColours.ts +++ b/src/constants/EmbedColours.ts @@ -1,8 +1,14 @@ export default class EmbedColours { + // General public static readonly Ok = 0x3050ba; public static readonly Success = 0x50c878; public static readonly Error = 0xff0000; + + // Colours public static readonly Grey = 0xd3d3d3; + public static readonly Green = 0x228B22; + + // Card Types public static readonly BronzeCard = 0xcd7f32; public static readonly SilverCard = 0xc0c0c0; public static readonly GoldCard = 0xffd700; -- 2.43.4 From 791bd6d2a6a29aa5e958cb365aae8e8219cef664 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 23 May 2024 17:59:52 +0100 Subject: [PATCH 2/3] Fix event not checking if the user who clicked the button is the same user --- src/buttonEvents/Sacrifice.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/buttonEvents/Sacrifice.ts b/src/buttonEvents/Sacrifice.ts index 5306764..86a21a2 100644 --- a/src/buttonEvents/Sacrifice.ts +++ b/src/buttonEvents/Sacrifice.ts @@ -24,6 +24,11 @@ export default class Sacrifice extends ButtonEvent { const userId = interaction.customId.split(" ")[2]; const cardNumber = interaction.customId.split(" ")[3]; + if (userId != interaction.user.id) { + await interaction.reply("Only the user who created this sacrifice can confirm it."); + return; + } + const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber); if (!cardInInventory) { @@ -94,6 +99,11 @@ export default class Sacrifice extends ButtonEvent { const userId = interaction.customId.split(" ")[2]; const cardNumber = interaction.customId.split(" ")[3]; + if (userId != interaction.user.id) { + await interaction.reply("Only the user who created this sacrifice can cancel it."); + return; + } + const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(userId, cardNumber); if (!cardInInventory) { -- 2.43.4 From 169bc62ccaa9e7d1300a8c953151687d18876d38 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 23 May 2024 18:00:54 +0100 Subject: [PATCH 3/3] Remove duplicated card name --- src/buttonEvents/Sacrifice.ts | 4 ++-- src/commands/sacrifice.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/buttonEvents/Sacrifice.ts b/src/buttonEvents/Sacrifice.ts index 86a21a2..a82ba81 100644 --- a/src/buttonEvents/Sacrifice.ts +++ b/src/buttonEvents/Sacrifice.ts @@ -73,7 +73,7 @@ export default class Sacrifice extends ButtonEvent { .setTitle("Card Sacrificed") .setDescription(description.join("\n")) .setColor(EmbedColours.Green) - .setFooter({ text: `${interaction.user.username} · ${cardData.card.name}` }); + .setFooter({ text: `${interaction.user.username}` }); const row = new ActionRowBuilder() .addComponents([ @@ -133,7 +133,7 @@ export default class Sacrifice extends ButtonEvent { .setTitle("Sacrifice Cancelled") .setDescription(description.join("\n")) .setColor(EmbedColours.Grey) - .setFooter({ text: `${interaction.user.username} · ${cardData.card.name}` }); + .setFooter({ text: `${interaction.user.username}` }); const row = new ActionRowBuilder() .addComponents([ diff --git a/src/commands/sacrifice.ts b/src/commands/sacrifice.ts index 0a72e4b..4d1c51a 100644 --- a/src/commands/sacrifice.ts +++ b/src/commands/sacrifice.ts @@ -51,7 +51,7 @@ export default class Sacrifice extends Command { .setTitle("Sacrifice") .setDescription(description.join("\n")) .setColor(EmbedColours.Error) - .setFooter({ text: `${interaction.user.username} · ${cardData.card.name}` }); + .setFooter({ text: `${interaction.user.username}` }); const row = new ActionRowBuilder() .addComponents([ -- 2.43.4