2023-02-13 04:51:17 +00:00
|
|
|
// dotenv for importing environment variables
|
2023-01-21 04:35:03 +00:00
|
|
|
const dotenv = require('dotenv');
|
|
|
|
const fs = require('fs');
|
2023-02-13 04:51:17 +00:00
|
|
|
// Configure Environment Variables
|
|
|
|
dotenv.config();
|
2023-01-21 04:35:03 +00:00
|
|
|
|
|
|
|
// Discord.js
|
|
|
|
const Discord = require('discord.js');
|
|
|
|
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = Discord;
|
|
|
|
|
|
|
|
// Various imports from other files
|
2023-02-13 04:51:17 +00:00
|
|
|
const debugMode = process.env.DEBUG;
|
2023-01-21 04:35:03 +00:00
|
|
|
const config = require('../data/config.json');
|
|
|
|
const strings = require('../data/strings.json');
|
|
|
|
const slashCommandFiles = fs.readdirSync('./slash-commands/').filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
const functions = {
|
|
|
|
// Functions for managing and creating Collections
|
2023-02-13 04:51:17 +00:00
|
|
|
collectionBuilders: {
|
2023-01-21 04:35:03 +00:00
|
|
|
// Create the collection of slash commands
|
|
|
|
slashCommands(client) {
|
|
|
|
if (!client.slashCommands) client.slashCommands = new Discord.Collection();
|
|
|
|
client.slashCommands.clear();
|
|
|
|
for (const file of slashCommandFiles) {
|
|
|
|
const slashCommand = require(`../slash-commands/${file}`);
|
|
|
|
if (slashCommand.data != undefined) {
|
|
|
|
client.slashCommands.set(slashCommand.data.name, slashCommand);
|
|
|
|
}
|
|
|
|
}
|
2023-02-13 04:51:17 +00:00
|
|
|
if (debugMode) console.log('Slash Commands Collection Built');
|
2023-01-21 04:35:03 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
builders: {
|
2023-02-13 04:51:17 +00:00
|
|
|
actionRows: {
|
|
|
|
example() {
|
|
|
|
// Create the button to go in the Action Row
|
|
|
|
const exampleButton = this.buttons.exampleButton();
|
|
|
|
// Create the Action Row with the Button in it, to be sent with the Embed
|
|
|
|
return new ActionRowBuilder()
|
|
|
|
.addComponents(exampleButton);
|
|
|
|
},
|
|
|
|
buttons: {
|
|
|
|
exampleButton() {
|
|
|
|
return new ButtonBuilder()
|
|
|
|
.setCustomId('id')
|
|
|
|
.setLabel('Label')
|
|
|
|
.setStyle(ButtonStyle.Primary);
|
|
|
|
}
|
|
|
|
}
|
2023-01-21 04:35:03 +00:00
|
|
|
},
|
2023-02-13 04:51:17 +00:00
|
|
|
embeds: {
|
|
|
|
help(private) {
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor(strings.embeds.color)
|
|
|
|
.setTitle(strings.help.title)
|
|
|
|
.setDescription(strings.help.content)
|
|
|
|
.setFooter({ text: strings.help.footer });
|
|
|
|
return { embeds: [embed] };
|
|
|
|
},
|
|
|
|
error(content) {
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor(strings.error.color)
|
|
|
|
.setTitle(strings.error.title)
|
|
|
|
.setDescription(content)
|
|
|
|
.setFooter({ text: strings.embeds.footer });
|
|
|
|
return { embeds: [embed], ephemeral: true };
|
|
|
|
},
|
|
|
|
info(content) {
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor(strings.embeds.infoColor)
|
|
|
|
.setTitle(strings.embeds.infoTitle)
|
|
|
|
.setDescription(content)
|
|
|
|
.setFooter({ text: strings.embeds.footer });
|
|
|
|
return { embeds: [embed], ephemeral: true };
|
|
|
|
}
|
2023-01-21 04:35:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = functions;
|