nodbot/slash-commands/pastas.js

30 lines
1.0 KiB
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');
2024-09-26 12:27:11 +00:00
const indexer = require('../CustomModules/Indexer.js');
2021-09-22 17:15:31 +00:00
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;
}
2024-09-26 12:27:11 +00:00
let iStorage = interaction.client.iStorage.get(interaction.id);
let indexedPastas = indexer(interaction.client.pastas, 0);
indexedPastas.pastasString = new String();
iStorage.page = 0;
for (const pasta of indexedPastas.thisPage) {
indexedPastas.pastasString += `${pasta.name}.pasta\n`;
}
2021-09-22 17:15:31 +00:00
const commandData = {
2024-09-26 12:27:11 +00:00
command: "/pastas",
author: interaction.member.displayName
2021-09-22 17:15:31 +00:00
};
2024-09-26 12:27:11 +00:00
interaction.reply(fn.embeds.pastas(commandData, indexedPastas));
2021-09-22 17:15:31 +00:00
},
};