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); interaction.update(strings.temp.gifs[newIndex].embed_url);
break; break;
case 'confirmGif': 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 = { const gifData = {
name: m.content.toLowerCase(), name: strings.temp.gifName,
embed_url: strings.temp.gifs[strings.temp.gifIndex].embed_url, embed_url: strings.temp.gifs[strings.temp.gifIndex].embed_url,
}; };
fn.upload.gif(gifData, client); fn.upload.gif(gifData, client);
m.reply(`I've saved the GIF as ${gifData.name}.gif`); interaction.update({ content: `I've saved the GIF as ${gifData.name}.gif`, components: [] });
fn.download.gifs(interaction.client);
collector.stop('success');
});
fn.download.gifs(interaction.client); fn.download.gifs(interaction.client);
break; break;
case 'nextGif': case 'nextGif':

View File

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