Compare commits
No commits in common. "d4c75845e56f7022c48bd5ef3a576f63571af0e6" and "b2807adf4d8f7dc38a5795cb22427c307232790f" have entirely different histories.
d4c75845e5
...
b2807adf4d
6 changed files with 1 additions and 69 deletions
|
@ -3,7 +3,6 @@ import { ButtonEvent } from "../type/buttonEvent";
|
||||||
import List from "./Effects/List";
|
import List from "./Effects/List";
|
||||||
import Use from "./Effects/Use";
|
import Use from "./Effects/Use";
|
||||||
import AppLogger from "../client/appLogger";
|
import AppLogger from "../client/appLogger";
|
||||||
import Buy from "./Effects/Buy";
|
|
||||||
|
|
||||||
export default class Effects extends ButtonEvent {
|
export default class Effects extends ButtonEvent {
|
||||||
public override async execute(interaction: ButtonInteraction) {
|
public override async execute(interaction: ButtonInteraction) {
|
||||||
|
@ -16,9 +15,6 @@ export default class Effects extends ButtonEvent {
|
||||||
case "use":
|
case "use":
|
||||||
await Use.Execute(interaction);
|
await Use.Execute(interaction);
|
||||||
break;
|
break;
|
||||||
case "buy":
|
|
||||||
await Buy.Execute(interaction);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
AppLogger.LogError("Buttons/Effects", `Unknown action, ${action}`);
|
AppLogger.LogError("Buttons/Effects", `Unknown action, ${action}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import {ButtonInteraction} from "discord.js";
|
|
||||||
import AppLogger from "../../client/appLogger";
|
|
||||||
|
|
||||||
export default class Buy {
|
|
||||||
public static async Execute(interaction: ButtonInteraction) {
|
|
||||||
const subaction = interaction.customId.split(" ")[2];
|
|
||||||
|
|
||||||
switch (subaction) {
|
|
||||||
case "confirm":
|
|
||||||
await this.Confirm(interaction);
|
|
||||||
break;
|
|
||||||
case "cancel":
|
|
||||||
await this.Cancel(interaction);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
AppLogger.LogError("Buy", `Unknown subaction, effects ${subaction}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Confirm(interaction: ButtonInteraction) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Cancel(interaction: ButtonInteraction) {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +1,4 @@
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
import EffectHelper from "../../helpers/EffectHelper";
|
|
||||||
|
|
||||||
export default async function Buy(interaction: CommandInteraction) {
|
export default async function Buy(interaction: CommandInteraction) {
|
||||||
const id = interaction.options.get("id", true).value!;
|
|
||||||
const quantity = interaction.options.get("quantity")?.value ?? 1;
|
|
||||||
|
|
||||||
const idValue = id.toString();
|
|
||||||
const quantityValue = Number(quantity);
|
|
||||||
|
|
||||||
const result = await EffectHelper.GenerateEffectBuyEmbed(interaction.user.id, idValue, quantityValue, false);
|
|
||||||
|
|
||||||
if (typeof result == "string") {
|
|
||||||
await interaction.reply(result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.reply({
|
|
||||||
embeds: [ result.embed ],
|
|
||||||
components: [ result.row ],
|
|
||||||
});
|
|
||||||
}
|
}
|
|
@ -49,8 +49,6 @@ test("GIVEN action is use, EXPECT use function to be called", async () => {
|
||||||
expect(List).not.toHaveBeenCalled();
|
expect(List).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.todo("GIVEN action is buy, EXPECT buy function to be called");
|
|
||||||
|
|
||||||
test("GIVEN action is invalid, EXPECT nothing to be called", async () => {
|
test("GIVEN action is invalid, EXPECT nothing to be called", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
interaction.customId = "effects invalid";
|
interaction.customId = "effects invalid";
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
describe("Execute", () => {
|
|
||||||
test.todo("GIVEN subaction is confirm, EXPECT confirm function executed");
|
|
||||||
|
|
||||||
test.todo("GIVEN subaction is cancel, EXPECT cancel function executed");
|
|
||||||
|
|
||||||
test.todo("GIVEN subaction is invalid, EXPECT error logged");
|
|
||||||
});
|
|
|
@ -1,12 +0,0 @@
|
||||||
import Buy from "../../../src/commands/effects/Buy";
|
|
||||||
import EffectHelper from "../../../src/helpers/EffectHelper";
|
|
||||||
|
|
||||||
jest.mock("../../../src/helpers/EffectHelper");
|
|
||||||
|
|
||||||
describe("Buy", () => {
|
|
||||||
test.todo("GIVEN result returns a string, EXPECT interaction replied with string");
|
|
||||||
|
|
||||||
test.todo("GIVEN result returns an embed, EXPECT interaction replied with embed and row");
|
|
||||||
|
|
||||||
test.todo("GIVEN quantity option is not supplied, EXPECT quantity to default to 1");
|
|
||||||
});
|
|
Loading…
Reference in a new issue