nodbot/slash-commands/gifs.js

29 lines
932 B
JavaScript
Raw Normal View History

2021-09-22 17:15:31 +00:00
const { SlashCommandBuilder } = require('@discordjs/builders');
const { config } = require('dotenv');
const fn = require('../functions.js');
const indexer = require('../CustomModules/Indexer.js');
2021-09-22 17:15:31 +00:00
module.exports = {
data: new SlashCommandBuilder()
.setName('gifs')
.setDescription('Get a list of currently saved GIFs.'),
execute(interaction) {
return new Promise((resolve, reject) => {
if (!interaction.client.gifs) {
interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!');
resolve();
}
let gifList = indexer(interaction.client.gifs, 0);
let gifsString = new String();
for (const gif of gifList.thisPage) {
gifsString += `[${gif.name}.gif](${gif.url})\n`;
}
const commandData = {
command: "/gifs",
author: interaction.member.displayName
};
interaction.reply(fn.embeds.gifs(commandData, gifsString, gifList.state));
2021-09-22 17:15:31 +00:00
});
},
};