MAJOR: Full rewrite of slash cmd loading system

The system of detecting, comparing & registering slash cmds has been rewritten and updated for future compatibility. This will break all current plugins (so please wait until they are updated)

=> Increased speed
=> All cmd params are now used when comparing
=> Future compability & removed deprecated functions
=> New universal utility interfaces for slash commands
=> And more!
This commit is contained in:
DJj123dj
2025-01-18 20:40:52 +01:00
parent 3a30152cb2
commit 03982f644e
3 changed files with 427 additions and 145 deletions
+6 -8
View File
@@ -394,15 +394,13 @@ const main = async () => {
openticket.log("Registering slash commands... (this can take up to 2 minutes)","system")
await openticket.events.get("onSlashCommandRegister").emit([openticket.client.slashCommands,openticket.client])
if (openticket.defaults.getDefault("slashCommandRegistering")){
//GLOBAL
await openticket.client.slashCommands.removeUnusedCommands() //remove all commands that aren't used
await openticket.client.slashCommands.createNewCommands() //create all new commands that don't exist yet
await openticket.client.slashCommands.updateExistingCommands(undefined,openticket.defaults.getDefault("forceSlashCommandRegistration")) //update all commands that need to be re-registered
//get all commands that are already registered in the bot
const cmds = await openticket.client.slashCommands.getAllRegisteredCommands()
//DEFAULT SERVER
await openticket.client.slashCommands.removeUnusedCommands(serverId) //remove all commands that aren't used
await openticket.client.slashCommands.createNewCommands(serverId) //create all new commands that don't exist yet
await openticket.client.slashCommands.updateExistingCommands(serverId) //update all commands that need to be re-registered
//remove unused cmds, create new cmds & update existing cmds
if (openticket.defaults.getDefault("allowSlashCommandRemoval")) await openticket.client.slashCommands.removeUnusedCommands(cmds.unused.map((cmd) => cmd.cmd))
await openticket.client.slashCommands.createNewCommands(cmds.unregistered.map((cmd) => cmd.instance))
await openticket.client.slashCommands.updateExistingCommands(cmds.registered.filter((cmd) => cmd.requiresUpdate || openticket.defaults.getDefault("forceSlashCommandRegistration")).map((cmd) => cmd.instance))
await openticket.events.get("afterSlashCommandsRegistered").emit([openticket.client.slashCommands,openticket.client])
}