Add query for filename
This commit is contained in:
parent
bfb06113b3
commit
b34700fd85
@ -7,8 +7,7 @@ module.exports = {
|
||||
description: 'Adds a given gif to the hardcoded list.',
|
||||
usage: '<search query>',
|
||||
execute(message, file) {
|
||||
message.author.createDM()
|
||||
.then(channel => {
|
||||
const channel = message.channel;
|
||||
const query = file.name;
|
||||
giphy.search(query)
|
||||
.then(res => {
|
||||
@ -23,10 +22,13 @@ module.exports = {
|
||||
"embed_url": res.data[i].images.original.url,
|
||||
"author": message.author
|
||||
};
|
||||
let embed = functions.createGifEmbed(data);
|
||||
let embed = functions.createGifEmbed(data, message.author, `${Object.values(file).join('.')}`);
|
||||
|
||||
// Send the first GIF result as an Embed
|
||||
channel.send(embed)
|
||||
.then(selfMessage => {
|
||||
// Add reactions to go back, forward, and confirm GIF choice.
|
||||
// React order is important so these are done in a chain
|
||||
selfMessage.react(emoji.previous).then(() => {
|
||||
selfMessage.react(emoji.confirm).then(() => {
|
||||
selfMessage.react(emoji.next);
|
||||
@ -42,19 +44,28 @@ module.exports = {
|
||||
case emoji.next:
|
||||
i++;
|
||||
data.embed_url = res.data[i].images.original.url;
|
||||
embed = functions.createGifEmbed(data);
|
||||
embed = functions.createGifEmbed(data, message.author, `${file.name}.${file.extension}`);
|
||||
if (selfMessage.editable) {
|
||||
selfMessage.edit(embed);
|
||||
}
|
||||
break;
|
||||
case emoji.confirm:
|
||||
channel.send('Saving GIF: ' + res.data[i].images.original.url);
|
||||
functions.saveGif(message, data.name, data.embed_url);
|
||||
channel.send('GIF Selected. What should I save the GIF as? (don\'t include the `.gif`)')
|
||||
.then(nameQueryMessage => {
|
||||
const nameCollectorFilter = nameMessage => nameMessage.author == message.author;
|
||||
const nameCollector = nameQueryMessage.channel.createMessageCollector(nameCollectorFilter, { time: 30000, max: 1 });
|
||||
|
||||
nameCollector.on('collect', nameMessage => {
|
||||
channel.send('The GIF has been saved as: ' + nameMessage.content + '.gif');
|
||||
functions.saveGif(message, nameMessage.content, data.embed_url);
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case emoji.previous:
|
||||
i--;
|
||||
data.embed_url = res.data[i].images.original.url;
|
||||
embed = functions.createGifEmbed(data);
|
||||
embed = functions.createGifEmbed(data, message.author, `${file.name}.${file.extension}`);
|
||||
if (selfMessage.editable) {
|
||||
selfMessage.edit(embed);
|
||||
}
|
||||
@ -67,7 +78,5 @@ module.exports = {
|
||||
}).catch(err => console.error(err));
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user