Skip to content

Commit 06b1f57

Browse files
committed
feat!: removed unused commands, share name across commands
1 parent 9ec25c2 commit 06b1f57

3 files changed

Lines changed: 26 additions & 83 deletions

File tree

src/commands/simple command.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/commands/slashes.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/commands/verify.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,31 @@ import { ButtonComponent, Discord, Slash, SlashOption } from "discordx";
1616

1717
@Discord()
1818
export class Command {
19+
name: string;
20+
21+
constructor(name: string) {
22+
this.name = name;
23+
}
24+
1925
@Slash({
2026
name: "verify",
2127
description: "Verify yourself and join Leagues of Code!",
2228
})
23-
async verify(interaction: CommandInteraction): Promise<void> {
29+
async verify(
30+
@SlashOption({
31+
description: "Enter your real name",
32+
name: "name",
33+
required: true,
34+
type: ApplicationCommandOptionType.String,
35+
})
36+
name: string | undefined,
37+
interaction: CommandInteraction
38+
): Promise<void> {
39+
this.name = name!;
40+
2441
await interaction.deferReply({ ephemeral: true });
2542

43+
// Class Buttons
2644
const PythonButton = new ButtonBuilder()
2745
.setLabel("Python")
2846
.setEmoji("<:python:1025584887337590834>")
@@ -35,31 +53,34 @@ export class Command {
3553
.setStyle(ButtonStyle.Primary)
3654
.setCustomId("cplus");
3755

56+
// Button rows
3857
const row =
3958
new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(
4059
PythonButton,
4160
CplusButton
4261
);
4362

44-
interaction.editReply({
45-
content: `${interaction.user.username}, Select your course!`,
63+
// Selector
64+
await interaction.editReply({
65+
content: `${name}, Select your course!`,
4666
components: [row],
4767
});
4868
}
4969

70+
// Events after button press
5071
@ButtonComponent({ id: "python" })
5172
PythonButton(interaction: ButtonInteraction): void {
5273
interaction.reply({
5374
ephemeral: true,
54-
content: `You've sent a verification request of **Python**<:python:1025584887337590834>! ${interaction.member}\nWait for an admin to approve your request.`,
75+
content: `***${this.name}***, you've sent a verification request of **Python**<:python:1025584887337590834>! ${interaction.member}\nWait for an admin to approve your request.`,
5576
});
5677
}
5778

5879
@ButtonComponent({ id: "cplus" })
5980
CplusButton(interaction: ButtonInteraction): void {
6081
interaction.reply({
6182
ephemeral: true,
62-
content: `You've sent a verification request of **C++**<:cplus:1025584885034913802>! ${interaction.member}\nWait for an admin to approve your request.`,
83+
content: `***${this.name}***, you've sent a verification request of **C++**<:cplus:1025584885034913802>! ${interaction.member}\nWait for an admin to approve your request.`,
6384
});
6485
}
6586
}

0 commit comments

Comments
 (0)