Restructure savegif & implement ephemeral response

This commit is contained in:
Skylar Grant 2022-06-10 22:29:01 -04:00
parent 2b7253ffae
commit 457c52ba0c
2 changed files with 11 additions and 12 deletions

10
main.js
View File

@ -107,18 +107,12 @@ client.on('interactionCreate', async interaction => {
interaction.update(strings.temp.gifs[newIndex].embed_url);
break;
case 'confirmGif':
interaction.update({ content: 'GIF Confirmed, what should I save it as?\n(*don\'t* include the .gif)', components: [] });
const collector = fn.collect.gifName(interaction);
collector.on('collect', m => {
const gifData = {
name: m.content.toLowerCase(),
name: strings.temp.gifName,
embed_url: strings.temp.gifs[strings.temp.gifIndex].embed_url,
};
fn.upload.gif(gifData, client);
m.reply(`I've saved the GIF as ${gifData.name}.gif`);
fn.download.gifs(interaction.client);
collector.stop('success');
});
interaction.update({ content: `I've saved the GIF as ${gifData.name}.gif`, components: [] });
fn.download.gifs(interaction.client);
break;
case 'nextGif':

View File

@ -18,6 +18,10 @@ module.exports = {
.addStringOption(option =>
option.setName('query')
.setDescription('Search Query')
.setRequired(true))
.addStringOption(option =>
option.setName('name')
.setDescription('What to save the gif as')
.setRequired(true)),
async execute(interaction) {
// Previous GIF button
@ -33,6 +37,7 @@ module.exports = {
// Get the query
const query = interaction.options.getString('query');
strings.temp.gifName = interaction.options.getString('name').toLowerCase();
// Search Tenor for the GIF
tenor.Search.Query(query, '10').then(res => {