Files
open-ticket/src/commands/autocomplete.ts
T
DJj123dj 82f2aeaa90 Added autocomplete to panel, ticket & move cmds
Ticket/panel options are now autocompleted instead of being a choice in the slash commands. This also results in the max amount of tickets limit to be increased to infinity.
2025-08-28 09:00:07 +02:00

32 lines
1.6 KiB
TypeScript

///////////////////////////////////////
//AUTOCOMPLETE COMMAND UTILS
///////////////////////////////////////
import {opendiscord, api, utilities} from "../index"
import * as discord from "discord.js"
export const registerAutocompleteResponders = async () => {
//PANEL ID AUTOCOMPLETE
opendiscord.responders.autocomplete.add(new api.ODAutocompleteResponder("opendiscord:panel-id","panel","id"))
opendiscord.responders.autocomplete.get("opendiscord:panel-id").workers.add(new api.ODWorker("opendiscord:panel-id",0,async (instance,params,source,cancel) => {
//create panel choices
const panelChoices : {name:string, value:string}[] = []
opendiscord.configs.get("opendiscord:panels").data.forEach((panel) => {
panelChoices.push({name:panel.name, value:panel.id})
})
await instance.filteredAutocomplete(panelChoices)
}))
//OPTION ID AUTOCOMPLETE
opendiscord.responders.autocomplete.add(new api.ODAutocompleteResponder("opendiscord:option-id",/ticket|move/,"id"))
opendiscord.responders.autocomplete.get("opendiscord:option-id").workers.add(new api.ODWorker("opendiscord:option-id",0,async (instance,params,source,cancel) => {
//create ticket choices
const ticketChoices : {name:string, value:string}[] = []
opendiscord.configs.get("opendiscord:options").data.forEach((option) => {
if (option.type != "ticket") return
ticketChoices.push({name:option.name, value:option.id})
})
instance.filteredAutocomplete(ticketChoices)
}))
}