nodbot/slash-commands/gifs.js

36 lines
1.0 KiB
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');
module.exports = {
data: new SlashCommandBuilder()
.setName('gifs')
.setDescription('Get a list of currently saved GIFs.'),
async execute(interaction) {
if (!interaction.client.gifs) {
interaction.reply('For some reason I don\'t have access to the collection of gifs. Sorry about that!');
return;
}
// const gifsMap = interaction.client.gifs.map(e => {e.name, e.url});
// const commandData = {
// gifs: [],
// command: 'gifs',
// author: interaction.user.tag,
// };
// for (const row of gifsMap) {
// commandData.gifs.push({
// id: row.id,
// name: row.name,
// });
// }
let gifList = [];
interaction.client.gifs.forEach(element => {
gifList.push(`[${element.name}](${element.url})`);
2021-09-22 17:15:31 +00:00
});
const commandData = {
command: "/gifs",
author: interaction.member.displayName
2021-09-22 17:15:31 +00:00
};
interaction.reply(fn.embeds.gifs(commandData, gifList));
2021-09-22 17:15:31 +00:00
},
};