WIP: Start creating tests for confirmation button event
Some checks failed
Test / build (push) Failing after 39s
Some checks failed
Test / build (push) Failing after 39s
This commit is contained in:
parent
416e30c042
commit
f745fdfbca
4 changed files with 95 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
|||
import {ButtonInteraction} from "discord.js";
|
||||
import AppLogger from "../../client/appLogger";
|
||||
import EffectHelper from "../../helpers/EffectHelper";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
|
||||
export default class Buy {
|
||||
public static async Execute(interaction: ButtonInteraction) {
|
||||
|
@ -18,6 +20,35 @@ export default class Buy {
|
|||
}
|
||||
|
||||
private static async Confirm(interaction: ButtonInteraction) {
|
||||
const id = interaction.customId.split(" ")[3];
|
||||
const quantity = interaction.customId.split(" ")[4];
|
||||
|
||||
if (!id || !quantity) {
|
||||
AppLogger.LogError("Buy Confirm", "Not enough parameters");
|
||||
return;
|
||||
}
|
||||
|
||||
const quantityNumber = Number(quantity);
|
||||
|
||||
if (!quantityNumber || quantityNumber < 1) {
|
||||
AppLogger.LogError("Buy Confirm", "Invalid number");
|
||||
return;
|
||||
}
|
||||
|
||||
const generatedEmbed = await EffectHelper.GenerateEffectBuyEmbed(interaction.user.id, id, quantityNumber, true);
|
||||
|
||||
if (typeof generatedEmbed == "string") {
|
||||
await interaction.reply(generatedEmbed);
|
||||
return;
|
||||
}
|
||||
|
||||
generatedEmbed.embed.setColor(EmbedColours.Success);
|
||||
generatedEmbed.embed.setFooter({ text: "Purchased" });
|
||||
|
||||
await interaction.update({
|
||||
embeds: [ generatedEmbed.embed ],
|
||||
components: [ generatedEmbed.row ],
|
||||
});
|
||||
}
|
||||
|
||||
private static async Cancel(interaction: ButtonInteraction) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue