fix last translation

This commit is contained in:
Mylloon 2022-11-06 01:47:32 +01:00
parent c7933d4aa9
commit 024beb00b2
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 29 additions and 21 deletions

View file

@ -148,10 +148,13 @@ export default {
// New reminder
case loc_default?.get(`c_${filename}_sub1_name`)
?.toLowerCase() ?? '': {
// If time is already renseigned
const time = interaction.options.getString(loc_default?.get(`c_${filename}_sub1_opt1_name`) as string);
if (time != null) {
// Cli
// Use the cli because we already have enough data
return newReminder(client, time, {
locale: loc,
message: interaction.options.getString(loc_default?.get('c_reminder_sub1_opt2_name') as string),
createdAt: interaction.createdAt.getTime(),
channelId: interaction.channelId,
@ -162,7 +165,7 @@ export default {
ephemeral: true,
}));
} else {
// GUI
// Show modal to user to get at least the time
const modal = new ModalBuilder()
.setCustomId('reminderGUI')
.setTitle(loc?.get('c_reminder_name').capitalize());
@ -181,7 +184,10 @@ export default {
.setPlaceholder(loc?.get('c_reminder_sub1_opt2_desc'))
.setRequired(false);
modal.addComponents(new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(timeGUI), new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(messageGUI));
modal.addComponents(
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(timeGUI),
new ActionRowBuilder<ModalActionRowComponentBuilder>().addComponents(messageGUI)
);
return interaction.showModal(modal);
}
@ -196,7 +202,8 @@ export default {
// Quand aucun utilisateur est spécifié, il faut affiché ses
// rappels, sinon affiché les rappels de la personne qui fait
// la commande.
break;
return interaction.reply('TODO');
}
// Delete a reminder
case loc_default?.get(`c_${filename}_sub3_name`)
@ -204,7 +211,8 @@ export default {
// TODO: Message simple qui indique que l'on a supprimé
// le reminder. Penser à check l'appartenance du reminder.
// On donne l'ID du reminder en option.
break;
return interaction.reply('TODO');
}
default: {
console.error(`${__filename}: unknown subcommand (${subcommand})`);

View file

@ -32,5 +32,6 @@
"c_reminder_sub3_name": "efface",
"c_reminder_sub3_desc": "Supprime un rappel",
"c_reminder_sub3_opt1_name": "ID",
"c_reminder_sub3_opt1_desc": "Rappel à supprimé"
"c_reminder_sub3_opt1_desc": "Rappel à supprimé",
"c_reminder1": "Un rappel a été configuré pour dans"
}

View file

@ -1,4 +1,5 @@
import { Client, ModalSubmitInteraction } from 'discord.js';
import { getLocale } from '../../utils/locales';
import { getFilename } from '../../utils/misc';
import { newReminder } from '../../utils/reminder';
@ -6,8 +7,9 @@ export default {
data: {
name: getFilename(__filename),
},
interaction: async (interaction: ModalSubmitInteraction, client: Client) => {
return newReminder(client, interaction.fields.fields.get('reminderGUI-time')?.value as string, {
interaction: async (interaction: ModalSubmitInteraction, client: Client) =>
newReminder(client, interaction.fields.fields.get('reminderGUI-time')?.value as string, {
locale: getLocale(client, interaction.locale),
message: interaction.fields.fields.get('reminderGUI-message')?.value ?? null,
createdAt: interaction.createdAt.getTime(),
channelId: interaction.channelId,
@ -16,6 +18,5 @@ export default {
}).then((msg) => interaction.reply({
content: msg as string,
ephemeral: true,
}));
},
})),
};

View file

@ -1,13 +1,14 @@
import { Client } from 'discord.js';
import { strToSeconds } from './time';
export enum OptionReminder {
enum OptionReminder {
Nothing,
Mention,
DirectMessage,
}
export type infoReminder = {
type infoReminder = {
locale: Map<string, Map<string, string>>,
message: string | null,
createdAt: number,
channelId: string | null,
@ -25,12 +26,11 @@ const splitTime = (time: string) => {
return { time: time, option: OptionReminder.Nothing };
};
export const newReminder = async (client: Client, time: string, info: infoReminder) => {
const data = splitTime(time);
// Add the remind to the db
return new Promise((ok, ko) => {
const res = client.db.run('INSERT INTO reminder ( \
export const newReminder = async (client: Client, time: string, info: infoReminder) =>
new Promise((ok, ko) => {
const data = splitTime(time);
// Add the remind to the db
client.db.run('INSERT INTO reminder ( \
data, expiration_date, option_id, channel_id, creation_date, user_id, guild_id \
) VALUES ( ?, ?, ?, ?, ?, ?, ?);', [
info.message,
@ -45,8 +45,6 @@ export const newReminder = async (client: Client, time: string, info: infoRemind
}
// Send confirmation to user
// TODO: local
ok(`ratio: ${info.message}, ${data.time}=${strToSeconds(data.time)}, ${data.option}, ${res}`);
ok(`${info.locale.get('c_reminder1')} ${data.time}.`);
});
});
};