nodbot/slash-commands/pastas.js

33 lines
927 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');
module.exports = {
data: new SlashCommandBuilder()
.setName('pastas')
.setDescription('Get a list of currently saved copypastas.'),
async execute(interaction) {
if (!interaction.client.pastas) {
2022-06-11 21:22:51 +00:00
interaction.reply({ content: 'For some reason I don\'t have access to the collection of copypastas. Sorry about that!', ephemeral: true });
2021-09-22 17:15:31 +00:00
return;
}
const commandData = {
author: interaction.user.tag,
command: interaction.commandName,
pastas: [],
};
const pastasMap = interaction.client.pastas.map(e => {
return {
id: e.id,
name: e.name,
};
});
for (const row of pastasMap) {
commandData.pastas.push({
id: row.id,
name: row.name,
});
}
2022-06-11 21:22:51 +00:00
interaction.reply({ content: fn.embeds.pastas(commandData), ephemeral: true });
2021-09-22 17:15:31 +00:00
},
};