* update buttons of reminder for the collect
* add a page arg
This commit is contained in:
parent
ffc395b4aa
commit
ff8561070a
4 changed files with 52 additions and 14 deletions
|
@ -1,12 +1,17 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, Client, Colors, EmbedBuilder } from 'discord.js';
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, Colors, EmbedBuilder, MessageComponentInteraction } 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 });
|
||||
interaction: async (_: MessageComponentInteraction, client: Client) => {
|
||||
// TODO: Dynamically change that
|
||||
const pageMax = 1;
|
||||
const page = 1;
|
||||
|
||||
// Fetch list
|
||||
client.db;
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
|
@ -19,7 +24,7 @@ export default {
|
|||
.setCustomId('reminderList-next')
|
||||
.setLabel('Next')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true),
|
||||
.setDisabled(page === pageMax ? true : false),
|
||||
);
|
||||
|
||||
|
||||
|
@ -28,9 +33,10 @@ export default {
|
|||
.setTitle('List title')
|
||||
.setDescription('List desc');
|
||||
|
||||
return interaction.editReply({
|
||||
return {
|
||||
content: 'next',
|
||||
embeds: [list],
|
||||
components: [row],
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, Client, Colors, EmbedBuilder } from 'discord.js';
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, Colors, EmbedBuilder, MessageComponentInteraction } 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 });
|
||||
interaction: async (_: MessageComponentInteraction, client: Client) => {
|
||||
// TODO: Dynamically change that
|
||||
const page = 1;
|
||||
|
||||
// Fetch list
|
||||
client.db;
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
|
@ -14,7 +18,7 @@ export default {
|
|||
.setCustomId('reminderList-prec')
|
||||
.setLabel('Prec')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true))
|
||||
.setDisabled(page === 1 ? true : false))
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('reminderList-next')
|
||||
|
@ -28,9 +32,10 @@ export default {
|
|||
.setTitle('List title')
|
||||
.setDescription('List desc');
|
||||
|
||||
return interaction.editReply({
|
||||
return {
|
||||
content: 'prec',
|
||||
embeds: [list],
|
||||
components: [row],
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { ModalActionRowComponentBuilder, SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, Client, Colors, EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } from 'discord.js';
|
||||
import { collect } from '../../buttons/loader';
|
||||
import { getLocale, getLocalizations } from '../../utils/locales';
|
||||
import { getFilename } from '../../utils/misc';
|
||||
import { checkOwnershipReminder, deleteReminder, getReminderInfo, newReminder } from '../../utils/reminder';
|
||||
|
@ -102,6 +103,24 @@ export default {
|
|||
getLocalizations(client, `c_${filename}_sub2_opt1_desc`)
|
||||
)
|
||||
)
|
||||
|
||||
// Page
|
||||
.addIntegerOption(option => option
|
||||
.setName(
|
||||
loc_default.get(`c_${filename}_sub2_opt2_name`)
|
||||
?.toLowerCase() ?? ''
|
||||
).setDescription(
|
||||
loc_default.get(`c_${filename}_sub2_opt2_desc`) ?? ''
|
||||
).setNameLocalizations(
|
||||
getLocalizations(
|
||||
client,
|
||||
`c_${filename}_sub2_opt2_name`,
|
||||
true
|
||||
)
|
||||
).setDescriptionLocalizations(
|
||||
getLocalizations(client, `c_${filename}_sub2_opt2_desc`)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// Delete a reminder
|
||||
|
@ -200,19 +219,25 @@ export default {
|
|||
user = interaction.user;
|
||||
}
|
||||
|
||||
const idPrec = 'reminderList-prec';
|
||||
const idNext = 'reminderList-next';
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('reminderList-prec')
|
||||
.setCustomId(idPrec)
|
||||
.setLabel('Prec')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true))
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId('reminderList-next')
|
||||
.setCustomId(idNext)
|
||||
.setLabel('Next')
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
);
|
||||
// Buttons interactions
|
||||
collect(client, interaction, idPrec);
|
||||
collect(client, interaction, idNext);
|
||||
|
||||
const list = new EmbedBuilder()
|
||||
.setColor(Colors.DarkGrey)
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
"c_reminder_sub2_desc": "Affiche la liste des rappels d'un utilisateur",
|
||||
"c_reminder_sub2_opt1_name": "utilisateur",
|
||||
"c_reminder_sub2_opt1_desc": "Affiche la liste de l'utilisateur en question",
|
||||
"c_reminder_sub2_opt2_name": "page",
|
||||
"c_reminder_sub2_opt2_desc": "Page à afficher",
|
||||
"c_reminder_sub3_name": "efface",
|
||||
"c_reminder_sub3_desc": "Supprime un rappel",
|
||||
"c_reminder_sub3_opt1_name": "id",
|
||||
|
|
Loading…
Reference in a new issue