@wolfstar/create-http-framework 2.1.4 → 2.2.0-next-20260831123711
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -18
- package/dist/index.js +241 -41
- package/package.json +7 -3
- package/template/{.env.hbs → base/.env.hbs} +2 -0
- package/template/base/README.md.hbs +33 -0
- package/template/base/src/commands/ping.js.hbs +18 -0
- package/template/{src → base/src}/commands/ping.ts.hbs +3 -1
- package/template/base/src/lib/setup/all.js.hbs +8 -0
- package/template/base/src/lib/setup/all.ts.hbs +8 -0
- package/template/base/src/lib/setup/logger.js.hbs +4 -0
- package/template/base/src/lib/setup/logger.ts.hbs +10 -0
- package/template/base/src/lib/types/augments.ts.hbs +13 -0
- package/template/base/src/main.js.hbs +31 -0
- package/template/base/src/main.ts.hbs +31 -0
- package/template/features/i18n/src/commands/ping.js.hbs +18 -0
- package/template/features/i18n/src/commands/ping.ts.hbs +15 -0
- package/template/features/i18n/src/locales/en-US/commands/ping.json +5 -0
- package/template/features/i18n/src/main.js.hbs +37 -0
- package/template/features/i18n/src/main.ts.hbs +37 -0
- package/template/features/subcommands/src/commands/math.js.hbs +41 -0
- package/template/features/subcommands/src/commands/math.ts.hbs +38 -0
- package/template/features/subcommands-advanced/src/commands/settings.js.hbs +53 -0
- package/template/features/subcommands-advanced/src/commands/settings.ts.hbs +70 -0
- package/template/features/subcommands-advanced-i18n/src/commands/settings.js.hbs +78 -0
- package/template/features/subcommands-advanced-i18n/src/commands/settings.ts.hbs +62 -0
- package/template/features/subcommands-advanced-i18n/src/locales/en-US/commands/settings.json +22 -0
- package/template/features/subcommands-i18n/src/commands/math.js.hbs +46 -0
- package/template/features/subcommands-i18n/src/commands/math.ts.hbs +43 -0
- package/template/features/subcommands-i18n/src/locales/en-US/commands/math.json +14 -0
- package/template/features/testing/tests/ping.test.js.hbs +33 -0
- package/template/features/testing/tests/ping.test.ts.hbs +33 -0
- package/template/features/testing/vitest.config.js.hbs +9 -0
- package/template/features/testing/vitest.config.ts.hbs +9 -0
- package/template/features/testing/vitest.setup.js.hbs +4 -0
- package/template/features/testing/vitest.setup.ts.hbs +4 -0
- package/template/features/testing-i18n/tests/ping.test.js.hbs +42 -0
- package/template/features/testing-i18n/tests/ping.test.ts.hbs +42 -0
- package/template/src/commands/ping.js.hbs +0 -12
- package/template/src/index.js.hbs +0 -8
- package/template/src/index.ts.hbs +0 -8
- /package/template/{.gitignore.hbs → base/.gitignore.hbs} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { setup as envRun } from '@wolfstar/env-utilities';
|
|
2
|
+
/* oxlint-disable import/first -- side-effect setup modules must run after env load preparation */
|
|
3
|
+
import './logger.js';
|
|
4
|
+
|
|
5
|
+
export function setup() {
|
|
6
|
+
// From dist/lib/setup → .env at the project root
|
|
7
|
+
envRun(new URL('../../../.env', import.meta.url));
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IntegerString } from '@wolfstar/env-utilities';
|
|
2
|
+
|
|
3
|
+
declare module '@wolfstar/env-utilities' {
|
|
4
|
+
interface Env {
|
|
5
|
+
DISCORD_CLIENT_ID: string;
|
|
6
|
+
DISCORD_TOKEN: string;
|
|
7
|
+
DISCORD_PUBLIC_KEY: string;
|
|
8
|
+
|
|
9
|
+
HTTP_ADDRESS: string;
|
|
10
|
+
HTTP_PORT: IntegerString;
|
|
11
|
+
HTTP_POST_PATH: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { setup } from './lib/setup/all.js';
|
|
2
|
+
import { envParseInteger, envParseString } from '@wolfstar/env-utilities';
|
|
3
|
+
import { Client, container } from '@wolfstar/http-framework';
|
|
4
|
+
import { createBanner } from '@wolfstar/start-banner';
|
|
5
|
+
import { morning } from 'gradient-string';
|
|
6
|
+
|
|
7
|
+
await setup();
|
|
8
|
+
|
|
9
|
+
const client = new Client();
|
|
10
|
+
await client.load();
|
|
11
|
+
|
|
12
|
+
const address = envParseString('HTTP_ADDRESS', '0.0.0.0');
|
|
13
|
+
const port = envParseInteger('HTTP_PORT', {{port}});
|
|
14
|
+
await client.listen({ address, port });
|
|
15
|
+
|
|
16
|
+
console.log(
|
|
17
|
+
morning.multiline(
|
|
18
|
+
createBanner({
|
|
19
|
+
logo: [' * . *', ' . ★ . ', '* . * .'],
|
|
20
|
+
name: ['{{name}}'],
|
|
21
|
+
extra: [
|
|
22
|
+
'',
|
|
23
|
+
`Loaded: ${container.stores.get('commands').size} commands`,
|
|
24
|
+
` : ${container.stores.get('interaction-handlers').size} interaction handlers`,
|
|
25
|
+
`Listening: ${address}:${port}`
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
container.logger.info('Ready');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { setup } from './lib/setup/all.js';
|
|
2
|
+
import { envParseInteger, envParseString } from '@wolfstar/env-utilities';
|
|
3
|
+
import { Client, container } from '@wolfstar/http-framework';
|
|
4
|
+
import { createBanner } from '@wolfstar/start-banner';
|
|
5
|
+
import { morning } from 'gradient-string';
|
|
6
|
+
|
|
7
|
+
await setup();
|
|
8
|
+
|
|
9
|
+
const client = new Client();
|
|
10
|
+
await client.load();
|
|
11
|
+
|
|
12
|
+
const address = envParseString('HTTP_ADDRESS', '0.0.0.0');
|
|
13
|
+
const port = envParseInteger('HTTP_PORT', {{port}});
|
|
14
|
+
await client.listen({ address, port });
|
|
15
|
+
|
|
16
|
+
console.log(
|
|
17
|
+
morning.multiline(
|
|
18
|
+
createBanner({
|
|
19
|
+
logo: [String.raw` * . *`, String.raw` . ★ . `, String.raw`* . * .`],
|
|
20
|
+
name: ['{{name}}'],
|
|
21
|
+
extra: [
|
|
22
|
+
'',
|
|
23
|
+
`Loaded: ${container.stores.get('commands').size} commands`,
|
|
24
|
+
` : ${container.stores.get('interaction-handlers').size} interaction handlers`,
|
|
25
|
+
`Listening: ${address}:${port}`
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
container.logger.info('Ready');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from '@wolfstar/http-framework';
|
|
2
|
+
import { applyLocalizedBuilder, getSupportedUserLanguageT } from '@wolfstar/plugin-i18next';
|
|
3
|
+
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';
|
|
4
|
+
|
|
5
|
+
export class PingCommand extends Command {
|
|
6
|
+
registerApplicationCommands(registry) {
|
|
7
|
+
registry.registerChatInputCommand((builder) =>
|
|
8
|
+
applyLocalizedBuilder(builder, 'commands/ping:name', 'commands/ping:description')
|
|
9
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
10
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
chatInputRun(interaction) {
|
|
15
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
16
|
+
return interaction.reply({ content: t('commands/ping:reply'), flags: MessageFlags.Ephemeral });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command, RegisterCommand } from '@wolfstar/http-framework';
|
|
2
|
+
import { applyLocalizedBuilder, getSupportedUserLanguageT } from '@wolfstar/plugin-i18next';
|
|
3
|
+
import { ApplicationIntegrationType, InteractionContextType, MessageFlags } from 'discord-api-types/v10';
|
|
4
|
+
|
|
5
|
+
@RegisterCommand((builder) =>
|
|
6
|
+
applyLocalizedBuilder(builder, 'commands/ping:name', 'commands/ping:description') //
|
|
7
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
8
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
9
|
+
)
|
|
10
|
+
export class PingCommand extends Command {
|
|
11
|
+
public override chatInputRun(interaction: Command.ChatInputInteraction) {
|
|
12
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
13
|
+
return interaction.reply({ content: t('commands/ping:reply'), flags: MessageFlags.Ephemeral });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import '@wolfstar/plugin-i18next/register';
|
|
2
|
+
import { setup } from './lib/setup/all.js';
|
|
3
|
+
import { envParseInteger, envParseString } from '@wolfstar/env-utilities';
|
|
4
|
+
import { Client, container } from '@wolfstar/http-framework';
|
|
5
|
+
import { createBanner } from '@wolfstar/start-banner';
|
|
6
|
+
import { morning } from 'gradient-string';
|
|
7
|
+
|
|
8
|
+
await setup();
|
|
9
|
+
|
|
10
|
+
const client = new Client({
|
|
11
|
+
i18n: {
|
|
12
|
+
defaultLanguageDirectory: new URL('locales', import.meta.url).pathname,
|
|
13
|
+
defaultName: 'en-US'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
await client.load();
|
|
17
|
+
|
|
18
|
+
const address = envParseString('HTTP_ADDRESS', '0.0.0.0');
|
|
19
|
+
const port = envParseInteger('HTTP_PORT', {{port}});
|
|
20
|
+
await client.listen({ address, port });
|
|
21
|
+
|
|
22
|
+
console.log(
|
|
23
|
+
morning.multiline(
|
|
24
|
+
createBanner({
|
|
25
|
+
logo: [' * . *', ' . ★ . ', '* . * .'],
|
|
26
|
+
name: ['{{name}}'],
|
|
27
|
+
extra: [
|
|
28
|
+
'',
|
|
29
|
+
`Loaded: ${container.stores.get('commands').size} commands`,
|
|
30
|
+
` : ${container.stores.get('interaction-handlers').size} interaction handlers`,
|
|
31
|
+
`Listening: ${address}:${port}`
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
container.logger.info('Ready');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import '@wolfstar/plugin-i18next/register';
|
|
2
|
+
import { setup } from './lib/setup/all.js';
|
|
3
|
+
import { envParseInteger, envParseString } from '@wolfstar/env-utilities';
|
|
4
|
+
import { Client, container } from '@wolfstar/http-framework';
|
|
5
|
+
import { createBanner } from '@wolfstar/start-banner';
|
|
6
|
+
import { morning } from 'gradient-string';
|
|
7
|
+
|
|
8
|
+
await setup();
|
|
9
|
+
|
|
10
|
+
const client = new Client({
|
|
11
|
+
i18n: {
|
|
12
|
+
defaultLanguageDirectory: new URL('locales', import.meta.url).pathname,
|
|
13
|
+
defaultName: 'en-US'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
await client.load();
|
|
17
|
+
|
|
18
|
+
const address = envParseString('HTTP_ADDRESS', '0.0.0.0');
|
|
19
|
+
const port = envParseInteger('HTTP_PORT', {{port}});
|
|
20
|
+
await client.listen({ address, port });
|
|
21
|
+
|
|
22
|
+
console.log(
|
|
23
|
+
morning.multiline(
|
|
24
|
+
createBanner({
|
|
25
|
+
logo: [String.raw` * . *`, String.raw` . ★ . `, String.raw`* . * .`],
|
|
26
|
+
name: ['{{name}}'],
|
|
27
|
+
extra: [
|
|
28
|
+
'',
|
|
29
|
+
`Loaded: ${container.stores.get('commands').size} commands`,
|
|
30
|
+
` : ${container.stores.get('interaction-handlers').size} interaction handlers`,
|
|
31
|
+
`Listening: ${address}:${port}`
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
container.logger.info('Ready');
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Command } from '@wolfstar/http-framework';
|
|
2
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
3
|
+
|
|
4
|
+
export class MathCommand extends Command {
|
|
5
|
+
registerApplicationCommands(registry) {
|
|
6
|
+
registry
|
|
7
|
+
.registerChatInputCommand((builder) =>
|
|
8
|
+
builder
|
|
9
|
+
.setName('math')
|
|
10
|
+
.setDescription('Perform basic arithmetic')
|
|
11
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
12
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
13
|
+
)
|
|
14
|
+
.registerSubcommand(
|
|
15
|
+
(builder) =>
|
|
16
|
+
builder
|
|
17
|
+
.setName('add')
|
|
18
|
+
.setDescription('Add two numbers')
|
|
19
|
+
.addIntegerOption((option) => option.setName('left').setDescription('The left operand').setRequired(true))
|
|
20
|
+
.addIntegerOption((option) => option.setName('right').setDescription('The right operand').setRequired(true)),
|
|
21
|
+
'add'
|
|
22
|
+
)
|
|
23
|
+
.registerSubcommand(
|
|
24
|
+
(builder) =>
|
|
25
|
+
builder
|
|
26
|
+
.setName('subtract')
|
|
27
|
+
.setDescription('Subtract two numbers')
|
|
28
|
+
.addIntegerOption((option) => option.setName('left').setDescription('The left operand').setRequired(true))
|
|
29
|
+
.addIntegerOption((option) => option.setName('right').setDescription('The right operand').setRequired(true)),
|
|
30
|
+
'subtract'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
add(interaction, { left, right }) {
|
|
35
|
+
return interaction.reply({ content: `${left} + ${right} = ${left + right}` });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
subtract(interaction, { left, right }) {
|
|
39
|
+
return interaction.reply({ content: `${left} - ${right} = ${left - right}` });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command, RegisterCommand, RegisterSubcommand } from '@wolfstar/http-framework';
|
|
2
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
3
|
+
|
|
4
|
+
@RegisterCommand((builder) =>
|
|
5
|
+
builder //
|
|
6
|
+
.setName('math')
|
|
7
|
+
.setDescription('Perform basic arithmetic')
|
|
8
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
9
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
10
|
+
)
|
|
11
|
+
export class MathCommand extends Command {
|
|
12
|
+
@RegisterSubcommand((builder) =>
|
|
13
|
+
builder //
|
|
14
|
+
.setName('add')
|
|
15
|
+
.setDescription('Add two numbers')
|
|
16
|
+
.addIntegerOption((option) => option.setName('left').setDescription('The left operand').setRequired(true))
|
|
17
|
+
.addIntegerOption((option) => option.setName('right').setDescription('The right operand').setRequired(true))
|
|
18
|
+
)
|
|
19
|
+
public add(interaction: Command.ChatInputInteraction, { left, right }: MathOptions) {
|
|
20
|
+
return interaction.reply({ content: `${left} + ${right} = ${left + right}` });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@RegisterSubcommand((builder) =>
|
|
24
|
+
builder //
|
|
25
|
+
.setName('subtract')
|
|
26
|
+
.setDescription('Subtract two numbers')
|
|
27
|
+
.addIntegerOption((option) => option.setName('left').setDescription('The left operand').setRequired(true))
|
|
28
|
+
.addIntegerOption((option) => option.setName('right').setDescription('The right operand').setRequired(true))
|
|
29
|
+
)
|
|
30
|
+
public subtract(interaction: Command.ChatInputInteraction, { left, right }: MathOptions) {
|
|
31
|
+
return interaction.reply({ content: `${left} - ${right} = ${left - right}` });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface MathOptions {
|
|
36
|
+
left: number;
|
|
37
|
+
right: number;
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Command } from '@wolfstar/http-framework';
|
|
2
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
3
|
+
|
|
4
|
+
export class SettingsCommand extends Command {
|
|
5
|
+
registerApplicationCommands(registry) {
|
|
6
|
+
registry
|
|
7
|
+
.registerChatInputCommand((builder) =>
|
|
8
|
+
builder
|
|
9
|
+
.setName('settings')
|
|
10
|
+
.setDescription('Manage your settings')
|
|
11
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
12
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
13
|
+
)
|
|
14
|
+
.registerSubcommandGroup((builder) => builder.setName('profile').setDescription('Manage your profile settings'))
|
|
15
|
+
.registerSubcommand((builder) => builder.setName('get').setDescription('View your current profile name'), 'profileGet', 'profile')
|
|
16
|
+
.registerSubcommand(
|
|
17
|
+
(builder) =>
|
|
18
|
+
builder
|
|
19
|
+
.setName('set')
|
|
20
|
+
.setDescription('Set your profile name')
|
|
21
|
+
.addStringOption((option) => option.setName('name').setDescription('The new profile name').setRequired(true)),
|
|
22
|
+
'profileSet',
|
|
23
|
+
'profile'
|
|
24
|
+
)
|
|
25
|
+
.registerSubcommandGroup((builder) => builder.setName('notifications').setDescription('Manage your notification settings'))
|
|
26
|
+
.registerSubcommand(
|
|
27
|
+
(builder) => builder.setName('enable').setDescription('Enable notifications'),
|
|
28
|
+
'notificationsEnable',
|
|
29
|
+
'notifications'
|
|
30
|
+
)
|
|
31
|
+
.registerSubcommand(
|
|
32
|
+
(builder) => builder.setName('disable').setDescription('Disable notifications'),
|
|
33
|
+
'notificationsDisable',
|
|
34
|
+
'notifications'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
profileGet(interaction) {
|
|
39
|
+
return interaction.reply({ content: 'Your profile name is not set yet.' });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
profileSet(interaction, { name }) {
|
|
43
|
+
return interaction.reply({ content: `Your profile name is now "${name}".` });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
notificationsEnable(interaction) {
|
|
47
|
+
return interaction.reply({ content: 'Notifications enabled.' });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
notificationsDisable(interaction) {
|
|
51
|
+
return interaction.reply({ content: 'Notifications disabled.' });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Command, RegisterCommand, RegisterSubcommand, RegisterSubcommandGroup } from '@wolfstar/http-framework';
|
|
2
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
3
|
+
|
|
4
|
+
@RegisterCommand((builder) =>
|
|
5
|
+
builder //
|
|
6
|
+
.setName('settings')
|
|
7
|
+
.setDescription('Manage your settings')
|
|
8
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
9
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
10
|
+
)
|
|
11
|
+
export class SettingsCommand extends Command {
|
|
12
|
+
@RegisterSubcommandGroup((builder) =>
|
|
13
|
+
builder //
|
|
14
|
+
.setName('profile')
|
|
15
|
+
.setDescription('Manage your profile settings')
|
|
16
|
+
)
|
|
17
|
+
@RegisterSubcommand(
|
|
18
|
+
(builder) =>
|
|
19
|
+
builder //
|
|
20
|
+
.setName('get')
|
|
21
|
+
.setDescription('View your current profile name'),
|
|
22
|
+
'profile'
|
|
23
|
+
)
|
|
24
|
+
public profileGet(interaction: Command.ChatInputInteraction) {
|
|
25
|
+
return interaction.reply({ content: 'Your profile name is not set yet.' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@RegisterSubcommand(
|
|
29
|
+
(builder) =>
|
|
30
|
+
builder //
|
|
31
|
+
.setName('set')
|
|
32
|
+
.setDescription('Set your profile name')
|
|
33
|
+
.addStringOption((option) => option.setName('name').setDescription('The new profile name').setRequired(true)),
|
|
34
|
+
'profile'
|
|
35
|
+
)
|
|
36
|
+
public profileSet(interaction: Command.ChatInputInteraction, { name }: SettingsProfileSetOptions) {
|
|
37
|
+
return interaction.reply({ content: `Your profile name is now "${name}".` });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@RegisterSubcommandGroup((builder) =>
|
|
41
|
+
builder //
|
|
42
|
+
.setName('notifications')
|
|
43
|
+
.setDescription('Manage your notification settings')
|
|
44
|
+
)
|
|
45
|
+
@RegisterSubcommand(
|
|
46
|
+
(builder) =>
|
|
47
|
+
builder //
|
|
48
|
+
.setName('enable')
|
|
49
|
+
.setDescription('Enable notifications'),
|
|
50
|
+
'notifications'
|
|
51
|
+
)
|
|
52
|
+
public notificationsEnable(interaction: Command.ChatInputInteraction) {
|
|
53
|
+
return interaction.reply({ content: 'Notifications enabled.' });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@RegisterSubcommand(
|
|
57
|
+
(builder) =>
|
|
58
|
+
builder //
|
|
59
|
+
.setName('disable')
|
|
60
|
+
.setDescription('Disable notifications'),
|
|
61
|
+
'notifications'
|
|
62
|
+
)
|
|
63
|
+
public notificationsDisable(interaction: Command.ChatInputInteraction) {
|
|
64
|
+
return interaction.reply({ content: 'Notifications disabled.' });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface SettingsProfileSetOptions {
|
|
69
|
+
name: string;
|
|
70
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Command } from '@wolfstar/http-framework';
|
|
2
|
+
import { applyLocalizedBuilder, getSupportedUserLanguageT } from '@wolfstar/plugin-i18next';
|
|
3
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
4
|
+
|
|
5
|
+
export class SettingsCommand extends Command {
|
|
6
|
+
registerApplicationCommands(registry) {
|
|
7
|
+
registry
|
|
8
|
+
.registerChatInputCommand((builder) =>
|
|
9
|
+
applyLocalizedBuilder(builder, 'commands/settings:name', 'commands/settings:description')
|
|
10
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
11
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
12
|
+
)
|
|
13
|
+
.registerSubcommandGroup((builder) =>
|
|
14
|
+
applyLocalizedBuilder(builder, 'commands/settings:profileName', 'commands/settings:profileDescription')
|
|
15
|
+
)
|
|
16
|
+
.registerSubcommand(
|
|
17
|
+
(builder) => applyLocalizedBuilder(builder, 'commands/settings:profileGetName', 'commands/settings:profileGetDescription'),
|
|
18
|
+
'profileGet',
|
|
19
|
+
'profile'
|
|
20
|
+
)
|
|
21
|
+
.registerSubcommand(
|
|
22
|
+
(builder) =>
|
|
23
|
+
applyLocalizedBuilder(builder, 'commands/settings:profileSetName', 'commands/settings:profileSetDescription').addStringOption(
|
|
24
|
+
(option) =>
|
|
25
|
+
applyLocalizedBuilder(
|
|
26
|
+
option,
|
|
27
|
+
'commands/settings:optionsNameName',
|
|
28
|
+
'commands/settings:optionsNameDescription'
|
|
29
|
+
).setRequired(true)
|
|
30
|
+
),
|
|
31
|
+
'profileSet',
|
|
32
|
+
'profile'
|
|
33
|
+
)
|
|
34
|
+
.registerSubcommandGroup((builder) =>
|
|
35
|
+
applyLocalizedBuilder(builder, 'commands/settings:notificationsName', 'commands/settings:notificationsDescription')
|
|
36
|
+
)
|
|
37
|
+
.registerSubcommand(
|
|
38
|
+
(builder) =>
|
|
39
|
+
applyLocalizedBuilder(
|
|
40
|
+
builder,
|
|
41
|
+
'commands/settings:notificationsEnableName',
|
|
42
|
+
'commands/settings:notificationsEnableDescription'
|
|
43
|
+
),
|
|
44
|
+
'notificationsEnable',
|
|
45
|
+
'notifications'
|
|
46
|
+
)
|
|
47
|
+
.registerSubcommand(
|
|
48
|
+
(builder) =>
|
|
49
|
+
applyLocalizedBuilder(
|
|
50
|
+
builder,
|
|
51
|
+
'commands/settings:notificationsDisableName',
|
|
52
|
+
'commands/settings:notificationsDisableDescription'
|
|
53
|
+
),
|
|
54
|
+
'notificationsDisable',
|
|
55
|
+
'notifications'
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
profileGet(interaction) {
|
|
60
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
61
|
+
return interaction.reply({ content: t('commands/settings:profileGetResult') });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
profileSet(interaction, { name }) {
|
|
65
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
66
|
+
return interaction.reply({ content: t('commands/settings:profileSetResult', { name }) });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
notificationsEnable(interaction) {
|
|
70
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
71
|
+
return interaction.reply({ content: t('commands/settings:notificationsEnableResult') });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
notificationsDisable(interaction) {
|
|
75
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
76
|
+
return interaction.reply({ content: t('commands/settings:notificationsDisableResult') });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Command, RegisterCommand, RegisterSubcommand, RegisterSubcommandGroup } from '@wolfstar/http-framework';
|
|
2
|
+
import { applyLocalizedBuilder, getSupportedUserLanguageT } from '@wolfstar/plugin-i18next';
|
|
3
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
4
|
+
|
|
5
|
+
@RegisterCommand((builder) =>
|
|
6
|
+
applyLocalizedBuilder(builder, 'commands/settings:name', 'commands/settings:description') //
|
|
7
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
8
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
9
|
+
)
|
|
10
|
+
export class SettingsCommand extends Command {
|
|
11
|
+
@RegisterSubcommandGroup((builder) =>
|
|
12
|
+
applyLocalizedBuilder(builder, 'commands/settings:profileName', 'commands/settings:profileDescription')
|
|
13
|
+
)
|
|
14
|
+
@RegisterSubcommand(
|
|
15
|
+
(builder) => applyLocalizedBuilder(builder, 'commands/settings:profileGetName', 'commands/settings:profileGetDescription'),
|
|
16
|
+
'profile'
|
|
17
|
+
)
|
|
18
|
+
public profileGet(interaction: Command.ChatInputInteraction) {
|
|
19
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
20
|
+
return interaction.reply({ content: t('commands/settings:profileGetResult') });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@RegisterSubcommand(
|
|
24
|
+
(builder) =>
|
|
25
|
+
applyLocalizedBuilder(builder, 'commands/settings:profileSetName', 'commands/settings:profileSetDescription').addStringOption(
|
|
26
|
+
(option) =>
|
|
27
|
+
applyLocalizedBuilder(option, 'commands/settings:optionsNameName', 'commands/settings:optionsNameDescription').setRequired(true)
|
|
28
|
+
),
|
|
29
|
+
'profile'
|
|
30
|
+
)
|
|
31
|
+
public profileSet(interaction: Command.ChatInputInteraction, { name }: SettingsProfileSetOptions) {
|
|
32
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
33
|
+
return interaction.reply({ content: t('commands/settings:profileSetResult', { name }) });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@RegisterSubcommandGroup((builder) =>
|
|
37
|
+
applyLocalizedBuilder(builder, 'commands/settings:notificationsName', 'commands/settings:notificationsDescription')
|
|
38
|
+
)
|
|
39
|
+
@RegisterSubcommand(
|
|
40
|
+
(builder) =>
|
|
41
|
+
applyLocalizedBuilder(builder, 'commands/settings:notificationsEnableName', 'commands/settings:notificationsEnableDescription'),
|
|
42
|
+
'notifications'
|
|
43
|
+
)
|
|
44
|
+
public notificationsEnable(interaction: Command.ChatInputInteraction) {
|
|
45
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
46
|
+
return interaction.reply({ content: t('commands/settings:notificationsEnableResult') });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@RegisterSubcommand(
|
|
50
|
+
(builder) =>
|
|
51
|
+
applyLocalizedBuilder(builder, 'commands/settings:notificationsDisableName', 'commands/settings:notificationsDisableDescription'),
|
|
52
|
+
'notifications'
|
|
53
|
+
)
|
|
54
|
+
public notificationsDisable(interaction: Command.ChatInputInteraction) {
|
|
55
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
56
|
+
return interaction.reply({ content: t('commands/settings:notificationsDisableResult') });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface SettingsProfileSetOptions {
|
|
61
|
+
name: string;
|
|
62
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "settings",
|
|
3
|
+
"description": "Manage your settings",
|
|
4
|
+
"profileName": "profile",
|
|
5
|
+
"profileDescription": "Manage your profile settings",
|
|
6
|
+
"profileGetName": "get",
|
|
7
|
+
"profileGetDescription": "View your current profile name",
|
|
8
|
+
"profileGetResult": "Your profile name is not set yet.",
|
|
9
|
+
"profileSetName": "set",
|
|
10
|
+
"profileSetDescription": "Set your profile name",
|
|
11
|
+
"profileSetResult": "Your profile name is now \"{{name}}\".",
|
|
12
|
+
"notificationsName": "notifications",
|
|
13
|
+
"notificationsDescription": "Manage your notification settings",
|
|
14
|
+
"notificationsEnableName": "enable",
|
|
15
|
+
"notificationsEnableDescription": "Enable notifications",
|
|
16
|
+
"notificationsEnableResult": "Notifications enabled.",
|
|
17
|
+
"notificationsDisableName": "disable",
|
|
18
|
+
"notificationsDisableDescription": "Disable notifications",
|
|
19
|
+
"notificationsDisableResult": "Notifications disabled.",
|
|
20
|
+
"optionsNameName": "name",
|
|
21
|
+
"optionsNameDescription": "The new profile name"
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from '@wolfstar/http-framework';
|
|
2
|
+
import { applyLocalizedBuilder, getSupportedUserLanguageT } from '@wolfstar/plugin-i18next';
|
|
3
|
+
import { ApplicationIntegrationType, InteractionContextType } from 'discord-api-types/v10';
|
|
4
|
+
|
|
5
|
+
export class MathCommand extends Command {
|
|
6
|
+
registerApplicationCommands(registry) {
|
|
7
|
+
registry
|
|
8
|
+
.registerChatInputCommand((builder) =>
|
|
9
|
+
applyLocalizedBuilder(builder, 'commands/math:name', 'commands/math:description')
|
|
10
|
+
.setIntegrationTypes(ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall)
|
|
11
|
+
.setContexts(InteractionContextType.Guild, InteractionContextType.BotDM, InteractionContextType.PrivateChannel)
|
|
12
|
+
)
|
|
13
|
+
.registerSubcommand(
|
|
14
|
+
(builder) =>
|
|
15
|
+
applyLocalizedBuilder(builder, 'commands/math:addName', 'commands/math:addDescription')
|
|
16
|
+
.addIntegerOption((option) =>
|
|
17
|
+
applyLocalizedBuilder(option, 'commands/math:optionsLeftName', 'commands/math:optionsLeftDescription').setRequired(true)
|
|
18
|
+
)
|
|
19
|
+
.addIntegerOption((option) =>
|
|
20
|
+
applyLocalizedBuilder(option, 'commands/math:optionsRightName', 'commands/math:optionsRightDescription').setRequired(true)
|
|
21
|
+
),
|
|
22
|
+
'add'
|
|
23
|
+
)
|
|
24
|
+
.registerSubcommand(
|
|
25
|
+
(builder) =>
|
|
26
|
+
applyLocalizedBuilder(builder, 'commands/math:subtractName', 'commands/math:subtractDescription')
|
|
27
|
+
.addIntegerOption((option) =>
|
|
28
|
+
applyLocalizedBuilder(option, 'commands/math:optionsLeftName', 'commands/math:optionsLeftDescription').setRequired(true)
|
|
29
|
+
)
|
|
30
|
+
.addIntegerOption((option) =>
|
|
31
|
+
applyLocalizedBuilder(option, 'commands/math:optionsRightName', 'commands/math:optionsRightDescription').setRequired(true)
|
|
32
|
+
),
|
|
33
|
+
'subtract'
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
add(interaction, { left, right }) {
|
|
38
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
39
|
+
return interaction.reply({ content: t('commands/math:addResult', { left, right, result: left + right }) });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
subtract(interaction, { left, right }) {
|
|
43
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
44
|
+
return interaction.reply({ content: t('commands/math:subtractResult', { left, right, result: left - right }) });
|
|
45
|
+
}
|
|
46
|
+
}
|