Skip to content

Commit b9cd4ab

Browse files
docs
1 parent 4c4b44e commit b9cd4ab

8 files changed

Lines changed: 57 additions & 9 deletions

File tree

src/commands/auctions/create/interactionListeners/action-buttons.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import {
77
confirmedAuctionCreationDisplayContainer
88
} from "../util/staticComponents";
99

10+
/**
11+
* Listens to the buttons on the container generated by the base listener
12+
* and handles the confirm and cancel actions.
13+
*/
1014
client.on("interactionCreate", async (interaction) => {
1115
if (!interaction.isButton()) return;
1216
if (!interaction.customId.startsWith("auction:create:")) return;

src/commands/auctions/create/interactionListeners/base.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import { MessageFlags, PrimaryEntryPointCommandInteraction } from "discord.js";
66
import AuctionCreator from "../util/AuctionCreator";
77
import { invalidAuctionCreateDisplayContainer } from "../util/staticComponents";
88

9+
10+
/**
11+
* Base listener of the auction create command. Verifies that the user
12+
* has a linked MinionAH account and initializes the AuctionCreator
13+
* to generate the confirmation display container.
14+
*/
915
client.on("interactionCreate", async (interaction) => {
1016
if (!interaction.isCommand()) return;
1117
if (interaction instanceof PrimaryEntryPointCommandInteraction) return;

src/commands/auctions/create/util/AuctionCreator.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ export default class AuctionCreator {
6464
AuctionCreator.auctionCreators.delete(username);
6565
}
6666

67+
/**
68+
* Finalizes the auction creation process and saves the auction to the database.
69+
* Although checked by the base listener, we re-validate the existence of the linked MinionAH user
70+
* since we use it anyway here.
71+
* @param username
72+
*/
6773
public static async confirmCreation(username: string) {
6874
const creator = AuctionCreator.auctionCreators.get(username);
6975
if (!creator) {
@@ -102,6 +108,11 @@ export default class AuctionCreator {
102108
});
103109
}
104110

111+
/**
112+
* Generates the confirmation display container for the auction creation process.
113+
* The container includes all the auction details and confirm/cancel buttons.
114+
* @returns
115+
*/
105116
public async getConfirmationDisplayContainer() {
106117
const minionData = await prisma.minion.findFirst({
107118
where: {

src/commands/auctions/delete/interactionListeners/action-buttons.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import genericErrorContainer from "$src/shared/displayContainers/genericErrorCon
44
import { MessageFlags } from "discord.js";
55
import auctionsDeleteComponents from "../util/auctionsDeleteComponents";
66

7+
8+
/**
9+
* Listens to the buttons on the container generated by the base listener
10+
* and handles the confirm and cancel actions for auction deletion.
11+
*/
712
client.on("interactionCreate", async (interaction) => {
813
if (!interaction.isButton()) return;
914
if (!interaction.customId.startsWith("auction:delete:")) return;
@@ -12,6 +17,7 @@ client.on("interactionCreate", async (interaction) => {
1217
const targetAuctionID = kv.get<string>(
1318
`auction:delete:pending:${interaction.user.username}`
1419
);
20+
1521
if (!targetAuctionID) {
1622
await interaction.reply({
1723
components: [
@@ -21,6 +27,7 @@ client.on("interactionCreate", async (interaction) => {
2127
});
2228
return;
2329
}
30+
2431
switch (action) {
2532
case "confirm": {
2633
await prisma.auction.delete({

src/commands/auctions/delete/interactionListeners/auctionID-autocomplete.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { kv, prisma } from "$src/central.config";
55
import { client } from "$src/discord/client";
66
import getLinkedMinionAHUser from "$src/shared/user/getLinkedMinionAHUser";
77

8+
9+
/**
10+
* Handles the autocomplete interaction for the auction ID
11+
* option in the auctions delete command, option `auction
12+
*/
813
client.on("interactionCreate", async (interaction) => {
914
if (!interaction.isAutocomplete()) return;
1015
if (interaction.commandName !== "auctions") return;

src/commands/auctions/delete/interactionListeners/base.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import getLinkedMinionAHUser from "$src/shared/user/getLinkedMinionAHUser";
77
import { MessageFlags, PrimaryEntryPointCommandInteraction } from "discord.js";
88
import auctionsDeleteComponents from "../util/auctionsDeleteComponents";
99

10+
11+
/**
12+
* Base listener of the auction delete command. Verifies that the user
13+
* has a linked MinionAH account and that the specified auction
14+
* exists and belongs to them. If so, generates a confirmation
15+
* display container for deletion.
16+
*/
1017
client.on("interactionCreate", async (interaction) => {
1118
if (!interaction.isCommand()) return;
1219
if (interaction instanceof PrimaryEntryPointCommandInteraction) return;

src/commands/auctions/myauctions/myauctions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ export default new SlashCommandSubcommandBuilder()
1717
.setName("myauctions")
1818
.setDescription("List your auctions");
1919

20+
21+
/**
22+
* Master (only) listener of the myauctions subcommand. Auction listings can
23+
* be handled by SearchSequence extensions using custom auction getters.
24+
* This listener verifies that the user has a linked MinionAH account
25+
* and initializes a SearchSequence to display their auctions.
26+
*/
2027
client.on("interactionCreate", async (interaction) => {
2128
if (!interaction.isCommand()) return;
2229
if (interaction instanceof PrimaryEntryPointCommandInteraction) return;

src/commands/auctions/myauctions/util/getMyAuctionsConstructor.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ interface GetAuctionsConfig {
1010
}
1111

1212
/**
13-
* Template function to get auctions for a specific user
13+
* Template function to get auctions for a specific user.
14+
* The resulting auctionGetter is used as the getter in SearchSequence
1415
* @param userID
1516
* @returns
1617
*/
@@ -35,11 +36,11 @@ export default function getMyAuctionsConstructor(userID: string) {
3536
// check for both minion type and tier
3637
...(minionType && minionTier
3738
? {
38-
minion_id: {
39-
contains: minionType.toUpperCase(),
40-
endsWith: "\\_" + minionTier
41-
}
39+
minion_id: {
40+
contains: minionType.toUpperCase(),
41+
endsWith: "\\_" + minionTier
4242
}
43+
}
4344
: {}),
4445
user_id: userID
4546
},
@@ -65,11 +66,11 @@ export default function getMyAuctionsConstructor(userID: string) {
6566
// check for both minion type and tier
6667
...(minionType && minionTier
6768
? {
68-
minion_id: {
69-
contains: minionType.toUpperCase(),
70-
endsWith: "\\_" + minionTier
71-
}
69+
minion_id: {
70+
contains: minionType.toUpperCase(),
71+
endsWith: "\\_" + minionTier
7272
}
73+
}
7374
: {}),
7475
user_id: userID
7576
}

0 commit comments

Comments
 (0)