This commit is contained in:
parent
38b0b8b301
commit
d4c75845e5
4 changed files with 39 additions and 1 deletions
|
@ -3,6 +3,7 @@ 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) {
|
||||||
|
@ -15,6 +16,9 @@ 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}`);
|
||||||
}
|
}
|
||||||
|
|
25
src/buttonEvents/Effects/Buy.ts
Normal file
25
src/buttonEvents/Effects/Buy.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
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) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,6 +49,8 @@ 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";
|
||||||
|
@ -63,4 +65,4 @@ test("GIVEN action is invalid, EXPECT nothing to be called", async () => {
|
||||||
|
|
||||||
expect(AppLogger.LogError).toHaveBeenCalledTimes(1);
|
expect(AppLogger.LogError).toHaveBeenCalledTimes(1);
|
||||||
expect(AppLogger.LogError).toHaveBeenCalledWith("Buttons/Effects", "Unknown action, invalid");
|
expect(AppLogger.LogError).toHaveBeenCalledWith("Buttons/Effects", "Unknown action, invalid");
|
||||||
});
|
});
|
||||||
|
|
7
tests/buttonEvents/Effects/Buy.test.ts
Normal file
7
tests/buttonEvents/Effects/Buy.test.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
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");
|
||||||
|
});
|
Loading…
Reference in a new issue