nodbot/CustomModules/Embeds.js

179 lines
6.0 KiB
JavaScript
Raw Normal View History

2024-09-29 17:01:25 +00:00
const { MessageActionRow, MessageButton, MessageEmbed, TextInputComponent } = require('discord.js');
2024-09-25 22:56:33 +00:00
module.exports = {
actionRows: {
gifSearchAR(state) {
// Setup the buttons
const previousButton = new MessageButton()
2024-09-25 22:56:33 +00:00
.setCustomId('prevGif')
.setLabel('⬅️')
.setStyle('SECONDARY');
const confirmButton = new MessageButton()
2024-09-25 22:56:33 +00:00
.setCustomId('confirmGif')
.setLabel('Select')
2024-09-25 22:56:33 +00:00
.setStyle('PRIMARY');
const nextButton = new MessageButton()
2024-09-25 22:56:33 +00:00
.setCustomId('nextGif')
.setLabel('➡️')
.setStyle('SECONDARY');
const cancelButton = new MessageButton()
2024-09-25 22:56:33 +00:00
.setCustomId('cancelGif')
.setLabel('Cancel')
2024-09-25 22:56:33 +00:00
.setStyle('DANGER');
switch (state) {
case 'first':
previousButton.setDisabled(true);
break;
case 'last':
nextButton.setDisabled(true);
break;
}
// Put the buttons into an ActionRow
return new MessageActionRow()
.addComponents(previousButton, confirmButton, nextButton, cancelButton);
},
gifsPageAR(state) {
// Setup the buttons
const previousButton = new MessageButton()
.setCustomId('prevGifsPage')
.setLabel('⬅️')
.setStyle('SECONDARY');
const nextButton = new MessageButton()
.setCustomId('nextGifsPage')
.setLabel('➡️')
.setStyle('SECONDARY');
switch (state) {
case 'first':
2024-09-26 12:09:09 +00:00
previousButton.setDisabled(true);
break;
case 'last':
2024-09-26 12:09:09 +00:00
nextButton.setDisabled(true);
break;
}
// Put the buttons into an ActionRow
return new MessageActionRow()
.addComponents(previousButton, nextButton);
},
requestsPageAR(state) {
// Setup the buttons
const previousButton = new MessageButton()
.setCustomId('prevRequestsPage')
.setLabel('⬅️')
.setStyle('SECONDARY');
const nextButton = new MessageButton()
.setCustomId('nextRequestsPage')
.setLabel('➡️')
.setStyle('SECONDARY');
2024-09-29 17:01:25 +00:00
const closeButton = new MessageButton()
.setCustomId('closeRequests')
.setLabel('Close Requests')
.setStyle('DANGER');
switch (state) {
case 'first':
2024-09-26 12:37:16 +00:00
previousButton.setDisabled(true);
break;
case 'last':
2024-09-26 12:37:16 +00:00
nextButton.setDisabled(true);
break;
}
// Put the buttons into an ActionRow
return new MessageActionRow()
2024-09-26 12:37:16 +00:00
.addComponents(previousButton, nextButton);
},
pastasPageAR(state) {
// Setup the buttons
const previousButton = new MessageButton()
.setCustomId('prevPastasPage')
.setLabel('⬅️')
.setStyle('SECONDARY');
const nextButton = new MessageButton()
.setCustomId('nextPastasPage')
.setLabel('➡️')
.setStyle('SECONDARY');
switch (state) {
case 'first':
2024-09-26 12:27:11 +00:00
previousButton.setDisabled(true);
break;
case 'last':
2024-09-26 12:27:11 +00:00
nextButton.setDisabled(true);
break;
}
// Put the buttons into an ActionRow
return new MessageActionRow()
2024-09-26 12:47:42 +00:00
.addComponents(previousButton, nextButton);
},
jointsPageAR(state) {
// Setup the buttons
const previousButton = new MessageButton()
2024-09-26 12:47:42 +00:00
.setCustomId('prevJointsPage')
.setLabel('⬅️')
.setStyle('SECONDARY');
const nextButton = new MessageButton()
2024-09-26 12:47:42 +00:00
.setCustomId('nextJointsPage')
.setLabel('➡️')
.setStyle('SECONDARY');
switch (state) {
case 'first':
2024-09-26 12:47:42 +00:00
previousButton.setDisabled(true);
break;
case 'last':
2024-09-26 12:47:42 +00:00
nextButton.setDisabled(true);
break;
}
// Put the buttons into an ActionRow
return new MessageActionRow()
2024-09-26 12:27:11 +00:00
.addComponents(previousButton, nextButton);
}
},
2024-09-29 17:01:25 +00:00
modals: {
closeRequestsModal() {
const requestNumberInput = new TextInputComponent()
.setCustomId('requestNumber')
.setLabel('Request Number')
.setPlaceholder('420')
.setMinLength(1)
.setMaxLength(5)
.setStyle('SHORT')
.setRequired(true);
const actionRow = new MessageActionRow()
.addComponents([requestNumberInput]);
return new Modal()
.setTitle('Close Request')
.setDescription('Please enter the number of the request you would like to close.')
.addComponents([actionRow]);
}
},
core: {
gifSearch(commandData, indexedGifs) {
return new MessageEmbed()
.setColor('#0099ff')
.setTitle('GIF Search')
.setImage(indexedGifs.thisPage[0].media_formats.gif.url)
.setFooter({ text: `Page ${indexedGifs.pagesString}` })
.addFields(
{ name: 'Query', value: `"${indexedGifs.query}"`, inline: true },
{ name: 'Saving As', value: `${indexedGifs.gifName}.gif`, inline: true },
);
}
2024-09-25 22:56:33 +00:00
}
}