feat: Reminders #44

Merged
Anri merged 54 commits from feat/reminders into main 2023-01-17 12:15:15 +01:00
3 changed files with 25 additions and 34 deletions
Showing only changes of commit 8ebc926d97 - Show all commits

View file

@ -220,38 +220,27 @@ export default {
} }
const page = interaction.options.getInteger(loc_default?.get(`c_${filename}_sub2_opt2_name`) as string) ?? 1; const page = interaction.options.getInteger(loc_default?.get(`c_${filename}_sub2_opt2_name`) as string) ?? 1;
const { remindersExists, list } = await embedListReminders(client, user, interaction.guildId, page, interaction.locale); const list = await embedListReminders(client, user, interaction.guildId, page, interaction.locale);
let row; const idPrec = 'reminderList-prec';
if (remindersExists) { const idNext = 'reminderList-next';
const idPrec = 'reminderList-prec'; const row = new ActionRowBuilder<ButtonBuilder>()
const idNext = 'reminderList-next'; .addComponents(
row = new ActionRowBuilder<ButtonBuilder>() new ButtonBuilder()
.addComponents( .setCustomId(idPrec)
new ButtonBuilder() .setLabel(loc.get('c_reminder12'))
.setCustomId(idPrec) .setStyle(ButtonStyle.Primary)
.setLabel('Prec') .setDisabled(true))
.setStyle(ButtonStyle.Primary) .addComponents(
.setDisabled(true)) new ButtonBuilder()
.addComponents( .setCustomId(idNext)
new ButtonBuilder() .setLabel(loc.get('c_reminder13'))
.setCustomId(idNext) .setStyle(ButtonStyle.Primary),
.setLabel('Next') );
.setStyle(ButtonStyle.Primary),
); // Buttons interactions
// Buttons interactions collect(client, interaction, idPrec);
collect(client, interaction, idPrec); collect(client, interaction, idNext);
collect(client, interaction, idNext);
} else {
const idUpdate = 'reminderList-update';
row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId(idUpdate)
.setLabel('Update')
.setStyle(ButtonStyle.Primary)
);
}
return await interaction.reply({ ephemeral: true, embeds: [list], components: [row] }); return await interaction.reply({ ephemeral: true, embeds: [list], components: [row] });
} }

View file

@ -46,5 +46,7 @@
"c_reminder8": "Expire dans", "c_reminder8": "Expire dans",
"c_reminder9": "Fais le", "c_reminder9": "Fais le",
"c_reminder10": "L'utilisateur n'a aucun rappel en attente ou page n°", "c_reminder10": "L'utilisateur n'a aucun rappel en attente ou page n°",
"c_reminder11": "vide !" "c_reminder11": "vide",
"c_reminder12": "Précédent",
"c_reminder13": "Suivant"
} }

View file

@ -313,8 +313,8 @@ export const embedListReminders = async (client: Client, user: User, guildId: st
} }
}); });
} else { } else {
embed.addFields({ name: '\u200b', value: `${loc.get('c_reminder10')}${page} ${loc.get('c_reminder11')}` }); embed.addFields({ name: '\u200b', value: `${loc.get('c_reminder10')}${page} ${loc.get('c_reminder11')}.` });
} }
return { remindersExists: reminders.length > 0 ? true : false, list: embed }; return embed;
}; };