Better function calling - ...argumentArray

This commit is contained in:
entar 2025-05-21 07:23:54 +07:00
parent 24fd053710
commit 9ae2359c8b
3 changed files with 13 additions and 6 deletions

View File

@ -21,7 +21,7 @@ module.exports = [
commands.forEach(commandList => {
commandList.forEach(command => {
if (command.hide) {
return // Go to next command if this one should show up
return // Go to next command if this one shouldnt show up
}
const field = {name: command.name, value: `Description: ${command.description || "None"}\nArguments: ${command.arguments || "None"}`}
embed.addFields(field)

View File

@ -6,12 +6,15 @@ module.exports = [
name: "helptest",
description: "Kill every1",
arguments: [GuildMember.name, GuildChannel.name],
run: (ctx, args) => {
if (!args[0].user) {
run: (ctx, member, channel) => {
if (!member.user) {
ctx.reply("Member invalid.")
}
if (!channel.id) {
ctx.reply("Member invalid.")
}
ctx.reply(`Member: ${args[0]}\nChannel: ${args[1]}`)
ctx.reply(`Member: ${member}\nChannel: ${channel}`)
}
}
},
]

View File

@ -114,7 +114,11 @@ client.on("messageCreate", (message) => {
}
// Run command
realCommand.run(message, args)
if (realCommand.arguments == ["any"] || realCommand.arguments == ["none"]) {
realCommand.run(message, args)
} else {
realCommand.run(message, ...args) // Example in extra.js
}
})
// After getting the command list we can export it