const { glob } = require("glob");
const { promisify } = require("util");
const { Client } = require("discord.js");
const mongoose = require("mongoose");
const globPromise = promisify(glob);
/**
* @param {Client} portle
*/
module.exports = async (portle) => {
const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`);
commandFiles.map((value) => {
const file = require(value);
const splitted = value.split("/");
const directory = splitted[splitted.length - 2];
if (file.name) {
const properties = { directory, ...file };
portle.commands.set(file.name, properties);
}
});
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
eventFiles.map((value) => require(value));
const slashCommands = await globPromise(
`${process.cwd()}/slash-cmds/*/*.js`
);
const arrayOfSlashCommands = [];
slashCommands.map((value) => {
const file = require(value);
if (!file?.name) return;
portle.slashCommands.set(file.name, file);
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
portle.on("ready", async () => {
await portle.guilds.cache
.get("884380331170484244")
.commands.set(arrayOfSlashCommands);
});
const mongooseURI = process.env.URI;
if (!mongooseURI) throw new Error("Unspecified mongoose connection string!");
mongoose.connect(mongooseURI).then(() => console.log('Connected to mongodb'));
};
I just started learning how to make slash commands and when I made one I restarted my bot Image of my commands, and now one of my slash commands is duplicated. How would I go about deleting the duplicate?
Command and Event Handler code below, I found on a yt tutorial.