init: reminder list

This commit is contained in:
Mylloon 2023-01-16 10:49:57 +01:00
parent 159d3b1528
commit 4bac943011
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 100 additions and 10 deletions

View file

@ -0,0 +1,36 @@
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, Client, Colors, EmbedBuilder } from 'discord.js';
import { getFilename } from '../../utils/misc';
export default {
data: {
name: getFilename(__filename),
},
interaction: async (interaction: ButtonInteraction, client: Client) => {
await interaction.deferReply({ ephemeral: true });
const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId('reminderList-prec')
.setLabel('Prec')
.setStyle(ButtonStyle.Primary))
.addComponents(
new ButtonBuilder()
.setCustomId('reminderList-next')
.setLabel('Next')
.setStyle(ButtonStyle.Primary)
.setDisabled(true),
);
const list = new EmbedBuilder()
.setColor(Colors.DarkGrey)
.setTitle('List title')
.setDescription('List desc');
return interaction.editReply({
embeds: [list],
components: [row],
});
},
};

View file

@ -0,0 +1,36 @@
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, Client, Colors, EmbedBuilder } from 'discord.js';
import { getFilename } from '../../utils/misc';
export default {
data: {
name: getFilename(__filename),
},
interaction: async (interaction: ButtonInteraction, client: Client) => {
await interaction.deferReply({ ephemeral: true });
const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId('reminderList-prec')
.setLabel('Prec')
.setStyle(ButtonStyle.Primary)
.setDisabled(true))
.addComponents(
new ButtonBuilder()
.setCustomId('reminderList-next')
.setLabel('Next')
.setStyle(ButtonStyle.Primary),
);
const list = new EmbedBuilder()
.setColor(Colors.DarkGrey)
.setTitle('List title')
.setDescription('List desc');
return interaction.editReply({
embeds: [list],
components: [row],
});
},
};

View file

@ -1,5 +1,5 @@
import { ModalActionRowComponentBuilder, SlashCommandBuilder } from '@discordjs/builders'; import { ModalActionRowComponentBuilder, SlashCommandBuilder } from '@discordjs/builders';
import { ActionRowBuilder, ChatInputCommandInteraction, Client, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js'; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, Client, Colors, EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
import { getLocale, getLocalizations } from '../../utils/locales'; import { getLocale, getLocalizations } from '../../utils/locales';
import { getFilename } from '../../utils/misc'; import { getFilename } from '../../utils/misc';
import { checkOwnershipReminder, deleteReminder, getReminderInfo, newReminder } from '../../utils/reminder'; import { checkOwnershipReminder, deleteReminder, getReminderInfo, newReminder } from '../../utils/reminder';
@ -194,15 +194,32 @@ export default {
// List reminders // List reminders
case loc_default?.get(`c_${filename}_sub2_name`) case loc_default?.get(`c_${filename}_sub2_name`)
?.toLowerCase() ?? '': { ?.toLowerCase() ?? '': {
// TODO: Liste dans un embed, naviguez entre les pages à l'aide // Which user to show
// de boutons à la place d'utiliser des réactions let user = interaction.options.getUser(loc_default?.get(`c_${filename}_sub2_opt1_name`) as string);
// cf. https://discordjs.guide/interactions/buttons.html#building-and-sending-buttons if (user == null) {
// Une option pour renseigné un utilisateur est disponible. user = interaction.user;
// Quand aucun utilisateur est spécifié, il faut affiché ses }
// rappels, sinon affiché les rappels de la personne qui fait
// la commande.
return interaction.reply('TODO'); const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId('reminderList-prec')
.setLabel('Prec')
.setStyle(ButtonStyle.Primary)
.setDisabled(true))
.addComponents(
new ButtonBuilder()
.setCustomId('reminderList-next')
.setLabel('Next')
.setStyle(ButtonStyle.Primary),
);
const list = new EmbedBuilder()
.setColor(Colors.DarkGrey)
.setTitle(`List title of ${user.tag}`)
.setDescription('List desc');
return await interaction.reply({ ephemeral: true, embeds: [list], components: [row] });
} }
// Delete a reminder // Delete a reminder
case loc_default?.get(`c_${filename}_sub3_name`) case loc_default?.get(`c_${filename}_sub3_name`)

View file

@ -36,5 +36,6 @@
"c_reminder_sub3_opt1_desc": "Rappel à supprimé", "c_reminder_sub3_opt1_desc": "Rappel à supprimé",
"c_reminder1": "Un rappel a été configuré pour dans", "c_reminder1": "Un rappel a été configuré pour dans",
"c_reminder2": "L'ID renseigné n'est pas valide.", "c_reminder2": "L'ID renseigné n'est pas valide.",
"c_reminder3": "Rappel non trouvé, pas sur le bon serveur ou qui ne vous appartiens pas." "c_reminder3": "Rappel non trouvé, pas sur le bon serveur ou qui ne vous appartiens pas.",
"c_reminder4": "Utilisateur inconnu."
} }