Add ability to save links as well as search for gifs

This commit is contained in:
Skylar Grant 2022-06-20 19:00:56 -04:00
parent 689ee529e2
commit 696e370c0b
1 changed files with 70 additions and 38 deletions

View File

@ -14,7 +14,11 @@ const strings = require('../strings.json');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName('savegif') .setName('savegif')
.setDescription('Search Tenor for a GIF to save') .setDescription('Save a GIF to Nodbot\'s database.')
.addSubcommand(subcommand =>
subcommand
.setName('searchgif')
.setDescription('Search Tenor for a GIF.')
.addStringOption(option => .addStringOption(option =>
option.setName('query') option.setName('query')
.setDescription('Search Query') .setDescription('Search Query')
@ -22,8 +26,24 @@ module.exports = {
.addStringOption(option => .addStringOption(option =>
option.setName('name') option.setName('name')
.setDescription('What to save the gif as') .setDescription('What to save the gif as')
.setRequired(true)), .setRequired(true))
)
.addSubcommand(subcommand =>
subcommand
.setName('enterurl')
.setDescription('Specify a URL to save.')
.addStringOption(option =>
option
.setName('url')
.setDescription('URL Link to the GIF')
.setRequired(true))
.addStringOption(option =>
option.setName('name')
.setDescription('What to save the gif as')
.setRequired(true))
),
async execute(interaction) { async execute(interaction) {
if (interaction.options.getSubcommand() == 'searchgif') {
// Previous GIF button // Previous GIF button
const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(true); const prevButton = new MessageButton().setCustomId('prevGif').setLabel('Previous GIF').setStyle('SECONDARY').setDisabled(true);
// Confirm GIF Button // Confirm GIF Button
@ -57,5 +77,17 @@ module.exports = {
} }
interaction.reply({ content: strings.temp.gifs[0].embed_url, components: [actionRow], ephemeral: true }); interaction.reply({ content: strings.temp.gifs[0].embed_url, components: [actionRow], ephemeral: true });
}); });
}
if (interaction.options.getSubcommand() == 'enterurl') {
const gifData = {
name: interaction.options.getString('name'),
embed_url: interaction.options.getString('url'),
};
fn.upload.gif(gifData, interaction.client);
interaction.reply({ content: `I've saved the GIF as ${gifData.name}.gif`, ephemeral: true });
fn.download.gifs(interaction.client);
}
}, },
}; };