Skip to content

Commit 1adba44

Browse files
committed
refactor: Update command consumers to use object arg
1 parent 34cc21c commit 1adba44

3 files changed

Lines changed: 22 additions & 20 deletions

File tree

src/commands/guides/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createCommand } from '../../util/commands.js';
44
import { loadMarkdownOptions } from '../../util/markdown.js';
55

66
const subjectsDir = new URL('./subjects/', import.meta.url);
7+
78
const subjectChoices = new Map<string, string>();
89

910
const loadChoices = async (): Promise<void> => {
@@ -18,8 +19,8 @@ const loadChoices = async (): Promise<void> => {
1819

1920
await loadChoices();
2021

21-
export const guidesCommand = createCommand(
22-
{
22+
export const guidesCommand = createCommand({
23+
data: {
2324
name: 'guides',
2425
description: 'Get a guide on a specific subject',
2526
type: ApplicationCommandType.ChatInput,
@@ -42,7 +43,7 @@ export const guidesCommand = createCommand(
4243
},
4344
],
4445
},
45-
async (interaction) => {
46+
execute: async (interaction) => {
4647
if (!interaction.isChatInputCommand()) return;
4748
const subject = interaction.options.getString('subject', true);
4849
const user = interaction.options.getUser('user');
@@ -69,5 +70,5 @@ export const guidesCommand = createCommand(
6970
await interaction.reply({ content: 'Guide sent!', flags: MessageFlags.Ephemeral });
7071

7172
return;
72-
}
73-
);
73+
},
74+
});

src/commands/ping.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { createCommand } from '../util/commands.js';
22

3-
export const pingCommand = createCommand(
4-
{
3+
export const pingCommand = createCommand({
4+
data: {
55
name: 'ping',
66
description: 'Replies with Pong!',
77
},
8-
async (interaction) => {
8+
execute: async (interaction) => {
99
const user = interaction.user;
1010
await interaction.reply(`<@${user.id}> Pong!`);
11-
}
12-
);
11+
},
12+
});

src/commands/tips/index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createCommand } from '../../util/commands.js';
44
import { loadMarkdownOptions } from '../../util/markdown.js';
55

66
const subjectsDir = new URL('./subjects/', import.meta.url);
7+
78
const subjectChoices = new Map<string, string>();
89

910
const loadChoices = async (): Promise<void> => {
@@ -18,8 +19,8 @@ const loadChoices = async (): Promise<void> => {
1819

1920
await loadChoices();
2021

21-
const slashCommand = createCommand(
22-
{
22+
const slashCommand = createCommand({
23+
data: {
2324
name: 'tips',
2425
description: 'Provide a helpful tip on a given subject',
2526
options: [
@@ -40,7 +41,7 @@ const slashCommand = createCommand(
4041
},
4142
],
4243
},
43-
async (interaction) => {
44+
execute: async (interaction) => {
4445
if (!interaction.isChatInputCommand()) return;
4546

4647
const subject = interaction.options.getString('subject', true);
@@ -66,16 +67,16 @@ const slashCommand = createCommand(
6667
});
6768

6869
await interaction.reply({ content: 'Tip sent!', ephemeral: true });
69-
}
70-
);
70+
},
71+
});
7172

7273
const contextMenuCommands = Array.from(subjectChoices).map(([key, value]) =>
73-
createCommand(
74-
{
74+
createCommand({
75+
data: {
7576
type: ApplicationCommandType.Message,
7677
name: `Tip: ${key}`,
7778
},
78-
async (interaction) => {
79+
execute: async (interaction) => {
7980
if (!interaction.isMessageContextMenuCommand()) return;
8081
const message = interaction.targetMessage;
8182

@@ -88,8 +89,8 @@ const contextMenuCommands = Array.from(subjectChoices).map(([key, value]) =>
8889
await interaction.editReply({ content: 'Tip sent!' });
8990

9091
return;
91-
}
92-
)
92+
},
93+
})
9394
);
9495

9596
export const tipsCommands = [slashCommand, ...contextMenuCommands];

0 commit comments

Comments
 (0)