feat: Reminders #44

Merged
Anri merged 54 commits from feat/reminders into main 2023-01-17 12:15:15 +01:00
Showing only changes of commit d4d3858ac7 - Show all commits

View file

@ -0,0 +1,144 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { Client, ChatInputCommandInteraction } from 'discord.js';
import { getLocale, getLocalizations } from '../../utils/locales';
import { getFilename } from '../../utils/misc';
export default {
data: (client: Client) => {
const filename = getFilename(__filename);
const loc_default = client.locales.get(client.config.default_lang);
if (!loc_default) {
return;
}
return new SlashCommandBuilder()
// Command
.setName(filename.toLowerCase())
.setDescription(loc_default.get(`c_${filename}_desc`) ?? '')
.setNameLocalizations(
getLocalizations(client, `c_${filename}_name`, true)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_desc`)
)
// New reminder
.addSubcommand(subcommand => subcommand
.setName(
loc_default.get(`c_${filename}_sub1_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub1_desc`) ?? ''
).setNameLocalizations(
getLocalizations(client, `c_${filename}_sub1_name`, true)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub1_desc`)
)
// Specified Time
.addStringOption(option => option
.setName(
loc_default.get(`c_${filename}_sub1_opt1_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub1_opt1_desc`) ?? ''
).setNameLocalizations(
getLocalizations(
client,
`c_${filename}_sub1_opt1_name`,
true
)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub1_opt1_desc`)
).setRequired(true)
)
// Specified message (not required)
.addStringOption(option => option
.setName(
loc_default.get(`c_${filename}_sub1_opt2_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub1_opt2_desc`) ?? ''
).setNameLocalizations(
getLocalizations(
client,
`c_${filename}_sub1_opt2_name`,
true
)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub1_opt2_desc`)
)
)
)
// List reminders
.addSubcommand(subcommand => subcommand
.setName(
loc_default.get(`c_${filename}_sub2_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub2_desc`) ?? ''
).setNameLocalizations(
getLocalizations(client, `c_${filename}_sub2_name`, true)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub2_desc`)
)
// User
.addStringOption(option => option
.setName(
loc_default.get(`c_${filename}_sub2_opt1_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub2_opt1_desc`) ?? ''
).setNameLocalizations(
getLocalizations(
client,
`c_${filename}_sub2_opt1_name`,
true
)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub2_opt1_desc`)
)
)
)
// Delete a reminder
.addSubcommand(subcommand => subcommand
.setName(
loc_default.get(`c_${filename}_sub3_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub3_desc`) ?? ''
).setNameLocalizations(
getLocalizations(client, `c_${filename}_sub3_name`, true)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub3_desc`)
)
// ID
.addStringOption(option => option
.setName(
loc_default.get(`c_${filename}_sub3_opt1_name`)
?.toLowerCase() ?? ''
).setDescription(
loc_default.get(`c_${filename}_sub3_opt1_desc`) ?? ''
).setNameLocalizations(
getLocalizations(
client,
`c_${filename}_sub3_opt1_name`,
true
)
).setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub3_opt1_desc`)
).setRequired(true)
),
);
},
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
const loc = getLocale(client, interaction.locale);
/* Votre code ici */
},
};