Noxic
Noxic
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
sorry bout that
15 replies
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
cuz i didnt see it because of discord
15 replies
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
this was posted way before i started to ask in that channel.
15 replies
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
hi, thanks for the answer. im getting help in #djs-help-v14 altough we cant seem to see why it doesnt want to work
15 replies
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
//in the above in code

let commandsArrayGlobal = [];

const commandFolders = [`commands`, `contextMenus`]

for (const folder of commandFolders) {

const files = fs.readdirSync(path.join(process.cwd(), folder)).filter(file => file.endsWith(".js"))
console.log(files)
for (const file of files) {
if(folder === "contextMenus") {
const commandName = file.name;
const command = require(path.join(process.cwd(), folder, file));
const contextMenu = command.execute;

/// client.commands.set(command.data.name, contextMenu)
commandsArrayGlobal.push({
name: command.name,
description: "",
type: command.type
})

}else if(folder === "commands") {
const commandName = file.split(".")[0]
const command = require(path.join(process.cwd(), folder, file));
const slashCommand = command.callback
client.commands.set(commandName, slashCommand)
commandsArrayGlobal.push({
name: commandName,
description: command.description,
options: command.options,
type: 1
})
}

}

}
//in client.ready

client.commands.set(commandsArrayGlobal)
//in the above in code

let commandsArrayGlobal = [];

const commandFolders = [`commands`, `contextMenus`]

for (const folder of commandFolders) {

const files = fs.readdirSync(path.join(process.cwd(), folder)).filter(file => file.endsWith(".js"))
console.log(files)
for (const file of files) {
if(folder === "contextMenus") {
const commandName = file.name;
const command = require(path.join(process.cwd(), folder, file));
const contextMenu = command.execute;

/// client.commands.set(command.data.name, contextMenu)
commandsArrayGlobal.push({
name: command.name,
description: "",
type: command.type
})

}else if(folder === "commands") {
const commandName = file.split(".")[0]
const command = require(path.join(process.cwd(), folder, file));
const slashCommand = command.callback
client.commands.set(commandName, slashCommand)
commandsArrayGlobal.push({
name: commandName,
description: command.description,
options: command.options,
type: 1
})
}

}

}
//in client.ready

client.commands.set(commandsArrayGlobal)
15 replies
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
@Cyph Erzz thanks, i made my own version, kinda. altough the contextmenus wont load
15 replies
DIAdiscord.js - Imagine an app
Created by Noxic on 4/25/2024 in #djs-questions
How to register commands using .set() ( ill explain in thread )
ok so in my command handler i used to do a for loop with a client.commands.create(), but that made alot of ghost commands after a while. I changed it to a for loop with a array.push() for the slash commands and then client.commands.set(). but i cant get it to register the contextmenu commands. i do push them to the array aswell
15 replies