nodbot/slash-commands/gifs.js

30 lines
966 B
JavaScript
Raw Permalink 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) {
2024-09-26 12:27:11 +00:00
if (!interaction.client.gifs) {
interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!');
return;
}
let iStorage = interaction.client.iStorage.get(interaction.id);
let indexedGifs = indexer(interaction.client.gifs, 0);
indexedGifs.gifsString = new String();
2024-09-26 12:27:11 +00:00
iStorage.page = 0;
2024-09-26 12:09:09 +00:00
2024-09-26 12:27:11 +00:00
for (const gif of indexedGifs.thisPage) {
indexedGifs.gifsString += `[${gif.name}.gif](${gif.url})\n`;
}
const commandData = {
command: "/gifs",
author: interaction.member.displayName
};
interaction.reply(fn.embeds.gifs(commandData, indexedGifs));
}
2021-09-22 17:15:31 +00:00
};