14 |
guild_id: string; |
guild_id: string; |
15 |
channel_id: string; |
channel_id: string; |
16 |
user_id?: string; |
user_id?: string; |
17 |
|
timeout?: number; |
18 |
embedBuilder: (options: EmbedBuilderOptions<T>) => MessageEmbed; |
embedBuilder: (options: EmbedBuilderOptions<T>) => MessageEmbed; |
19 |
actionRowBuilder?: (options: { first: boolean, last: boolean, next: boolean, back: boolean }) => MessageActionRow<MessageButton>; |
actionRowBuilder?: (options: { first: boolean, last: boolean, next: boolean, back: boolean }) => MessageActionRow<MessageButton>; |
20 |
} |
} |
61 |
|
|
62 |
options.embeds ??= []; |
options.embeds ??= []; |
63 |
options.embeds.push(this.getEmbed(page)); |
options.embeds.push(this.getEmbed(page)); |
64 |
console.log(options.embeds); |
|
65 |
options.components ??= []; |
options.components ??= []; |
66 |
options.components.push(this.getActionRow(actionRowOptionsDup)); |
options.components.push(this.getActionRow(actionRowOptionsDup)); |
67 |
|
|
73 |
return this.options.actionRowBuilder({ first, last, next, back }); |
return this.options.actionRowBuilder({ first, last, next, back }); |
74 |
} |
} |
75 |
|
|
76 |
const actionRow = new MessageActionRow<MessageButton>; |
const actionRow = new MessageActionRow<MessageButton>(); |
77 |
|
|
78 |
actionRow.addComponents( |
actionRow.addComponents( |
79 |
new MessageButton() |
new MessageButton() |
108 |
interactionType: 'MESSAGE_COMPONENT', |
interactionType: 'MESSAGE_COMPONENT', |
109 |
componentType: 'BUTTON', |
componentType: 'BUTTON', |
110 |
message, |
message, |
111 |
time: 60_000, |
time: this.options.timeout ?? 60_000, |
112 |
filter: interaction => { |
filter: interaction => { |
113 |
if (interaction.inGuild() && (!this.options.user_id || interaction.user.id === this.options.user_id)) { |
if (interaction.inGuild() && (!this.options.user_id || interaction.user.id === this.options.user_id)) { |
114 |
return true; |
return true; |
127 |
return; |
return; |
128 |
} |
} |
129 |
|
|
130 |
|
// await interaction.deferUpdate(); |
131 |
|
|
132 |
const maxPage = Math.ceil(this.data.length / this.options.limit); |
const maxPage = Math.ceil(this.data.length / this.options.limit); |
133 |
const componentOptions = { first: true, last: true, next: true, back: true }; |
const componentOptions = { first: true, last: true, next: true, back: true }; |
134 |
|
|
165 |
}); |
}); |
166 |
|
|
167 |
collector.on("end", async () => { |
collector.on("end", async () => { |
168 |
await message.edit({ components: [this.getActionRow({ first: false, last: false, next: false, back: false })] }); |
const component = message.components[0]; // this.getActionRow({ first: false, last: false, next: false, back: false }) |
169 |
|
|
170 |
|
for (const i in component.components) { |
171 |
|
component.components[i].disabled = true; |
172 |
|
} |
173 |
|
|
174 |
|
await message.edit({ components: [component] }); |
175 |
}); |
}); |
176 |
} |
} |
177 |
} |
} |