Made built-in cmds compatible with slash update

This commit is contained in:
DJj123dj
2025-01-18 20:41:12 +01:00
parent 03982f644e
commit c3474fb017
+55 -44
View File
@@ -36,7 +36,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"help", name:"help",
description:lang.getTranslation("commands.help"), description:lang.getTranslation("commands.help"),
dmPermission:true contexts:[discord.InteractionContextType.BotDM,discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
})) }))
//PANEL //PANEL
@@ -44,7 +45,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"panel", name:"panel",
description:lang.getTranslation("commands.panel"), description:lang.getTranslation("commands.panel"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"id", name:"id",
@@ -62,15 +64,12 @@ export const loadAllSlashCommands = async () => {
] ]
},(current) => { },(current) => {
//check if this slash command needs to be updated //check if this slash command needs to be updated
if (!current.options) return true const idOption = current.options.find((opt) => opt.name == "id" && opt.type == acot.String)
const idOption = current.options.find((opt) => opt.name == "id" && opt.type == acot.String) as discord.ApplicationCommandStringOptionData|undefined if (!idOption || idOption.choices.length != panelChoices.length) return true
if (!idOption || !idOption.choices || idOption.choices.length != panelChoices.length) return true if (!panelChoices.every((panel) => {
else if (!panelChoices.every((panel) => { return (idOption.choices.find((c) => c.value == panel.value && c.name == panel.name)) ? true : false
if (!idOption.choices) return false
else if (!idOption.choices.find((choice) => choice.value == panel.value && choice.name == panel.name)) return false
else return true
})) return true })) return true
else return false return false
})) }))
//TICKET (when enabled) //TICKET (when enabled)
@@ -78,7 +77,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"ticket", name:"ticket",
description:lang.getTranslation("commands.ticket"), description:lang.getTranslation("commands.ticket"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"id", name:"id",
@@ -90,15 +90,12 @@ export const loadAllSlashCommands = async () => {
] ]
},(current) => { },(current) => {
//check if this slash command needs to be updated //check if this slash command needs to be updated
if (!current.options) return true const idOption = current.options.find((opt) => opt.name == "id" && opt.type == acot.String)
const idOption = current.options.find((opt) => opt.name == "id" && opt.type == acot.String) as discord.ApplicationCommandStringOptionData|undefined if (!idOption || idOption.choices.length != ticketChoices.length) return true
if (!idOption || !idOption.choices || idOption.choices.length != ticketChoices.length) return true if (!ticketChoices.every((ticket) => {
else if (!ticketChoices.every((ticket) => { return (idOption.choices.find((c) => c.value == ticket.value && c.name == ticket.name)) ? true : false
if (!idOption.choices) return false
else if (!idOption.choices.find((choice) => choice.value == ticket.value && choice.name == ticket.name)) return false
else return true
})) return true })) return true
else return false return false
})) }))
//CLOSE //CLOSE
@@ -106,7 +103,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"close", name:"close",
description:lang.getTranslation("commands.close"), description:lang.getTranslation("commands.close"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -122,7 +120,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"delete", name:"delete",
description:lang.getTranslation("commands.delete"), description:lang.getTranslation("commands.delete"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -142,7 +141,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"delete", name:"delete",
description:lang.getTranslation("commands.delete"), description:lang.getTranslation("commands.delete"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -158,7 +158,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"reopen", name:"reopen",
description:lang.getTranslation("commands.reopen"), description:lang.getTranslation("commands.reopen"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -174,7 +175,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"claim", name:"claim",
description:lang.getTranslation("commands.claim"), description:lang.getTranslation("commands.claim"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"user", name:"user",
@@ -196,7 +198,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"unclaim", name:"unclaim",
description:lang.getTranslation("commands.unclaim"), description:lang.getTranslation("commands.unclaim"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -212,7 +215,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"pin", name:"pin",
description:lang.getTranslation("commands.pin"), description:lang.getTranslation("commands.pin"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -228,7 +232,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"unpin", name:"unpin",
description:lang.getTranslation("commands.unpin"), description:lang.getTranslation("commands.unpin"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reason", name:"reason",
@@ -244,7 +249,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"move", name:"move",
description:lang.getTranslation("commands.move"), description:lang.getTranslation("commands.move"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"id", name:"id",
@@ -262,15 +268,12 @@ export const loadAllSlashCommands = async () => {
] ]
},(current) => { },(current) => {
//check if this slash command needs to be updated //check if this slash command needs to be updated
if (!current.options) return true const idOption = current.options.find((opt) => opt.name == "id" && opt.type == acot.String)
const idOption = current.options.find((opt) => opt.name == "id" && opt.type == acot.String) as discord.ApplicationCommandStringOptionData|undefined if (!idOption || idOption.choices.length != ticketChoices.length) return true
if (!idOption || !idOption.choices || idOption.choices.length != ticketChoices.length) return true if (!ticketChoices.every((ticket) => {
else if (!ticketChoices.every((ticket) => { return (idOption.choices.find((c) => c.value == ticket.value && c.name == ticket.name)) ? true : false
if (!idOption.choices) return false
else if (!idOption.choices.find((choice) => choice.value == ticket.value && choice.name == ticket.name)) return false
else return true
})) return true })) return true
else return false return false
})) }))
//RENAME //RENAME
@@ -278,7 +281,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"rename", name:"rename",
description:lang.getTranslation("commands.rename"), description:lang.getTranslation("commands.rename"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"name", name:"name",
@@ -301,7 +305,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"add", name:"add",
description:lang.getTranslation("commands.add"), description:lang.getTranslation("commands.add"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"user", name:"user",
@@ -323,7 +328,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"remove", name:"remove",
description:lang.getTranslation("commands.remove"), description:lang.getTranslation("commands.remove"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"user", name:"user",
@@ -345,7 +351,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"blacklist", name:"blacklist",
description:lang.getTranslation("commands.blacklist"), description:lang.getTranslation("commands.blacklist"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"view", name:"view",
@@ -411,7 +418,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"stats", name:"stats",
description:lang.getTranslation("commands.stats"), description:lang.getTranslation("commands.stats"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"reset", name:"reset",
@@ -465,7 +473,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"clear", name:"clear",
description:lang.getTranslation("commands.clear"), description:lang.getTranslation("commands.clear"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"filter", name:"filter",
@@ -491,7 +500,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"autoclose", name:"autoclose",
description:lang.getTranslation("commands.autoclose"), description:lang.getTranslation("commands.autoclose"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"disable", name:"disable",
@@ -534,7 +544,8 @@ export const loadAllSlashCommands = async () => {
type:act.ChatInput, type:act.ChatInput,
name:"autodelete", name:"autodelete",
description:lang.getTranslation("commands.autodelete"), description:lang.getTranslation("commands.autodelete"),
dmPermission:false, contexts:[discord.InteractionContextType.Guild],
integrationTypes:[discord.ApplicationIntegrationType.GuildInstall],
options:[ options:[
{ {
name:"disable", name:"disable",