Type simplifications (for documentation)
This commit is contained in:
+138
-104
@@ -77,23 +77,141 @@ export interface ODJsonConfig_DefaultMessageSettingsType {
|
|||||||
*/
|
*/
|
||||||
export type ODJsonConfig_DefaultCmdPermissionSettingsType = "admin"|"everyone"|"none"|string
|
export type ODJsonConfig_DefaultCmdPermissionSettingsType = "admin"|"everyone"|"none"|string
|
||||||
|
|
||||||
/**## ODJsonConfig_DefaultGeneral `default_class`
|
/**## ODJsonConfig_DefaultInfo `interface`
|
||||||
* This is a special class that adds type definitions & typescript to the ODJsonConfig class.
|
* This object contains a few URLs and metadata for the config.
|
||||||
* It doesn't add any extra features!
|
|
||||||
*
|
|
||||||
* This default class is made for the `general.json` config!
|
|
||||||
*/
|
*/
|
||||||
export class ODJsonConfig_DefaultGeneral extends ODJsonConfig {
|
export interface ODJsonConfig_DefaultInfo {
|
||||||
declare data: {
|
|
||||||
/**This object contains a few URLs and metadata for the config. */
|
|
||||||
_INFO:{
|
|
||||||
/**A link to the Open Ticket documentation. */
|
/**A link to the Open Ticket documentation. */
|
||||||
support:string,
|
support:string,
|
||||||
/**A link to the DJdj Development discord server. */
|
/**A link to the DJdj Development discord server. */
|
||||||
discord:string,
|
discord:string,
|
||||||
/**The version of Open Ticket this config is compatible with. */
|
/**The version of Open Ticket this config is compatible with. */
|
||||||
version:string
|
version:string
|
||||||
},
|
}
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultSystemLogs `interface`
|
||||||
|
* All settings related to the log channel.
|
||||||
|
*/
|
||||||
|
export interface ODJsonConfig_DefaultSystemLogs {
|
||||||
|
/**Enable logging. Individual actions should still be added via the `"system"."messages"..."logs"` */
|
||||||
|
enabled:boolean,
|
||||||
|
/**The channel to send logs to. */
|
||||||
|
channel:string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultSystemLimits `interface`
|
||||||
|
* All settings related to global ticket limits.
|
||||||
|
*/
|
||||||
|
export interface ODJsonConfig_DefaultSystemLimits {
|
||||||
|
/**Enable global ticket limits. */
|
||||||
|
enabled:boolean,
|
||||||
|
/**The maximum amount of tickets that are allowed in the server at the same time. */
|
||||||
|
globalMaximum:number,
|
||||||
|
/**The maximum amount of tickets that a user is allowed to create at the same time. */
|
||||||
|
userMaximum:number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultSystemPermissions `interface`
|
||||||
|
* Configure permissions for all Open Ticket commands & actions.
|
||||||
|
*/
|
||||||
|
export interface ODJsonConfig_DefaultSystemPermissions {
|
||||||
|
help:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
panel:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
ticket:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
close:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
delete:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
reopen:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
claim:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
unclaim:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
pin:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
unpin:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
move:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
rename:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
add:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
remove:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
blacklist:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
stats:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
clear:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
autoclose:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
||||||
|
autodelete:ODJsonConfig_DefaultCmdPermissionSettingsType
|
||||||
|
}
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultSystemMessages `interface`
|
||||||
|
* Configure dm & log messages for all Open Ticket commands & actions.
|
||||||
|
*/
|
||||||
|
export interface ODJsonConfig_DefaultSystemMessages {
|
||||||
|
creation:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
closing:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
deleting:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
reopening:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
claiming:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
pinning:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
adding:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
removing:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
renaming:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
moving:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
blacklisting:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
roleAdding:ODJsonConfig_DefaultMessageSettingsType,
|
||||||
|
roleRemoving:ODJsonConfig_DefaultMessageSettingsType
|
||||||
|
}
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultSystem `interface`
|
||||||
|
* All settings related to the ticket system.
|
||||||
|
*/
|
||||||
|
export interface ODJsonConfig_DefaultSystem {
|
||||||
|
/**Remove all participants (except admins) from the ticket when it's closed. */
|
||||||
|
removeParticipantsOnClose:boolean,
|
||||||
|
/**Reply with an ephemeral message when a ticket is created. */
|
||||||
|
replyOnTicketCreation:boolean,
|
||||||
|
/**Reply with an ephemeral message when reaction roles are changed. */
|
||||||
|
replyOnReactionRole:boolean,
|
||||||
|
/**Use a translated config checker in the console. */
|
||||||
|
useTranslatedConfigChecker:boolean,
|
||||||
|
/**Prefer slash-commands over text-commands when displaying them in menu's and messages. */
|
||||||
|
preferSlashOverText:boolean,
|
||||||
|
/**Reply with "unknown command" when the prefix is used without a valid command. */
|
||||||
|
sendErrorOnUnknownCommand:boolean,
|
||||||
|
/**Display the question fields (in a ticket message) in code blocks. */
|
||||||
|
questionFieldsInCodeBlock:boolean,
|
||||||
|
/**Disable the (✅❌) buttons and directly run the action. */
|
||||||
|
disableVerifyBars:boolean,
|
||||||
|
/**Display error embeds/messages with red instead of the default bot color. */
|
||||||
|
useRedErrorEmbeds:boolean,
|
||||||
|
/**The emoji style used in the bot. This will affect all embeds, titles & messages in the bot. */
|
||||||
|
emojiStyle:"before"|"after"|"double"|"disabled",
|
||||||
|
|
||||||
|
/**Enable/disable the ticket claim & unclaim button in the ticket message. */
|
||||||
|
enableTicketClaimButtons:boolean,
|
||||||
|
/**Enable/disable the ticket close & re-open button in the ticket message. */
|
||||||
|
enableTicketCloseButtons:boolean,
|
||||||
|
/**Enable/disable the ticket pin & unpin button in the ticket message. */
|
||||||
|
enableTicketPinButtons:boolean,
|
||||||
|
/**Enable/disable the ticket delete button in the ticket message. */
|
||||||
|
enableTicketDeleteButtons:boolean,
|
||||||
|
/**Enable/disable the "with reason" button for all actions in the ticket message. */
|
||||||
|
enableTicketActionWithReason:boolean,
|
||||||
|
/**Enable/disable the delete without transcript feature (button & /delete command). */
|
||||||
|
enableDeleteWithoutTranscript:boolean,
|
||||||
|
|
||||||
|
/**All settings related to the log channel. */
|
||||||
|
logs:ODJsonConfig_DefaultSystemLogs,
|
||||||
|
|
||||||
|
/**All settings related to global ticket limits. */
|
||||||
|
limits:ODJsonConfig_DefaultSystemLimits,
|
||||||
|
|
||||||
|
/**Configure permissions for all Open Ticket commands & actions. */
|
||||||
|
permissions:ODJsonConfig_DefaultSystemPermissions,
|
||||||
|
|
||||||
|
/**Configure dm & log messages for all Open Ticket commands & actions. */
|
||||||
|
messages:ODJsonConfig_DefaultSystemMessages
|
||||||
|
}
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultGeneralData `interface`
|
||||||
|
* All contents of the `general.json` config file.
|
||||||
|
*/
|
||||||
|
export interface ODJsonConfig_DefaultGeneralData {
|
||||||
|
/**This object contains a few URLs and metadata for the config. */
|
||||||
|
_INFO:ODJsonConfig_DefaultInfo,
|
||||||
|
|
||||||
/**The token of the bot. (Empty when using `tokenFromENV`) */
|
/**The token of the bot. (Empty when using `tokenFromENV`) */
|
||||||
token:string,
|
token:string,
|
||||||
@@ -120,101 +238,17 @@ export class ODJsonConfig_DefaultGeneral extends ODJsonConfig {
|
|||||||
status:ODJsonConfig_DefaultStatusType,
|
status:ODJsonConfig_DefaultStatusType,
|
||||||
|
|
||||||
/**All settings related to the ticket system. */
|
/**All settings related to the ticket system. */
|
||||||
system:{
|
system:ODJsonConfig_DefaultSystem
|
||||||
/**Remove all participants (except admins) from the ticket when it's closed. */
|
}
|
||||||
removeParticipantsOnClose:boolean,
|
|
||||||
/**Reply with an ephemeral message when a ticket is created. */
|
|
||||||
replyOnTicketCreation:boolean,
|
|
||||||
/**Reply with an ephemeral message when reaction roles are changed. */
|
|
||||||
replyOnReactionRole:boolean,
|
|
||||||
/**Use a translated config checker in the console. */
|
|
||||||
useTranslatedConfigChecker:boolean,
|
|
||||||
/**Prefer slash-commands over text-commands when displaying them in menu's and messages. */
|
|
||||||
preferSlashOverText:boolean,
|
|
||||||
/**Reply with "unknown command" when the prefix is used without a valid command. */
|
|
||||||
sendErrorOnUnknownCommand:boolean,
|
|
||||||
/**Display the question fields (in a ticket message) in code blocks. */
|
|
||||||
questionFieldsInCodeBlock:boolean,
|
|
||||||
/**Disable the (✅❌) buttons and directly run the action. */
|
|
||||||
disableVerifyBars:boolean,
|
|
||||||
/**Display error embeds/messages with red instead of the default bot color. */
|
|
||||||
useRedErrorEmbeds:boolean,
|
|
||||||
/**The emoji style used in the bot. This will affect all embeds, titles & messages in the bot. */
|
|
||||||
emojiStyle:"before"|"after"|"double"|"disabled",
|
|
||||||
|
|
||||||
|
/**## ODJsonConfig_DefaultGeneral `default_class`
|
||||||
/**Enable/disable the ticket claim & unclaim button in the ticket message. */
|
* This is a special class that adds type definitions & typescript to the ODJsonConfig class.
|
||||||
enableTicketClaimButtons:boolean,
|
* It doesn't add any extra features!
|
||||||
/**Enable/disable the ticket close & re-open button in the ticket message. */
|
*
|
||||||
enableTicketCloseButtons:boolean,
|
* This default class is made for the `general.json` config!
|
||||||
/**Enable/disable the ticket pin & unpin button in the ticket message. */
|
*/
|
||||||
enableTicketPinButtons:boolean,
|
export class ODJsonConfig_DefaultGeneral extends ODJsonConfig {
|
||||||
/**Enable/disable the ticket delete button in the ticket message. */
|
declare data: ODJsonConfig_DefaultGeneralData
|
||||||
enableTicketDeleteButtons:boolean,
|
|
||||||
/**Enable/disable the "with reason" button for all actions in the ticket message. */
|
|
||||||
enableTicketActionWithReason:boolean,
|
|
||||||
/**Enable/disable the delete without transcript feature (button & /delete command). */
|
|
||||||
enableDeleteWithoutTranscript:boolean,
|
|
||||||
|
|
||||||
/**All settings related to the log channel. */
|
|
||||||
logs:{
|
|
||||||
/**Enable logging. Individual actions should still be added via the `"system"."messages"..."logs"` */
|
|
||||||
enabled:boolean,
|
|
||||||
/**The channel to send logs to. */
|
|
||||||
channel:string
|
|
||||||
},
|
|
||||||
|
|
||||||
/**All settings related to global ticket limits. */
|
|
||||||
limits:{
|
|
||||||
/**Enable global ticket limits. */
|
|
||||||
enabled:boolean,
|
|
||||||
/**The maximum amount of tickets that are allowed in the server at the same time. */
|
|
||||||
globalMaximum:number,
|
|
||||||
/**The maximum amount of tickets that a user is allowed to create at the same time. */
|
|
||||||
userMaximum:number
|
|
||||||
},
|
|
||||||
|
|
||||||
/**Configure permissions for all Open Ticket commands & actions. */
|
|
||||||
permissions:{
|
|
||||||
help:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
panel:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
ticket:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
close:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
delete:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
reopen:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
claim:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
unclaim:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
pin:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
unpin:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
move:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
rename:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
add:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
remove:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
blacklist:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
stats:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
clear:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
autoclose:ODJsonConfig_DefaultCmdPermissionSettingsType,
|
|
||||||
autodelete:ODJsonConfig_DefaultCmdPermissionSettingsType
|
|
||||||
},
|
|
||||||
|
|
||||||
/**Configure dm & log messages for all Open Ticket commands & actions. */
|
|
||||||
messages:{
|
|
||||||
creation:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
closing:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
deleting:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
reopening:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
claiming:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
pinning:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
adding:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
removing:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
renaming:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
moving:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
blacklisting:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
roleAdding:ODJsonConfig_DefaultMessageSettingsType,
|
|
||||||
roleRemoving:ODJsonConfig_DefaultMessageSettingsType
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**## ODJsonConfig_DefaultOptionType `interface`
|
/**## ODJsonConfig_DefaultOptionType `interface`
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ export type ODValidJsonType = string|number|boolean|object|ODValidJsonType[]|nul
|
|||||||
*/
|
*/
|
||||||
export type ODInterfaceWithPartialProperty<Interface,Key extends keyof Interface> = Omit<Interface,Key> & Partial<Pick<Interface,Key>>
|
export type ODInterfaceWithPartialProperty<Interface,Key extends keyof Interface> = Omit<Interface,Key> & Partial<Pick<Interface,Key>>
|
||||||
|
|
||||||
|
/**## ODDiscordIdType `type`
|
||||||
|
* A list of all available discord ID types. Used in the config checker.
|
||||||
|
*/
|
||||||
|
export type ODDiscordIdType = "role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message"
|
||||||
|
|
||||||
/**## ODId `class`
|
/**## ODId `class`
|
||||||
* This is an Open Ticket identifier.
|
* This is an Open Ticket identifier.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
//CONFIG CHECKER MODULE
|
//CONFIG CHECKER MODULE
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
import { ODId, ODManager, ODManagerData, ODValidId, ODValidJsonType } from "./base"
|
import { ODDiscordIdType, ODId, ODManager, ODManagerData, ODValidId, ODValidJsonType } from "./base"
|
||||||
import { ODConfig } from "./config"
|
import { ODConfig } from "./config"
|
||||||
import { ODLanguageManager } from "./language"
|
import { ODLanguageManager } from "./language"
|
||||||
import { ODDebugger } from "./console"
|
import { ODDebugger } from "./console"
|
||||||
@@ -218,6 +218,11 @@ export class ODCheckerTranslationRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODCheckerFunctionCallback `type`
|
||||||
|
* This is the function used in the `ODCheckerFunction` class.
|
||||||
|
*/
|
||||||
|
export type ODCheckerFunctionCallback = (manager:ODCheckerManager, functions:ODCheckerFunctionManager) => ODCheckerResult
|
||||||
|
|
||||||
/**## ODCheckerFunction `class`
|
/**## ODCheckerFunction `class`
|
||||||
* This is an Open Ticket config checker function.
|
* This is an Open Ticket config checker function.
|
||||||
*
|
*
|
||||||
@@ -225,10 +230,10 @@ export class ODCheckerTranslationRegister {
|
|||||||
* It's mostly used for things that need to be checked globally!
|
* It's mostly used for things that need to be checked globally!
|
||||||
*/
|
*/
|
||||||
export class ODCheckerFunction extends ODManagerData {
|
export class ODCheckerFunction extends ODManagerData {
|
||||||
/**The function itself :) */
|
/**The function which will be executed globally after all config checkers. */
|
||||||
func: (manager:ODCheckerManager, functions:ODCheckerFunctionManager) => ODCheckerResult
|
func: ODCheckerFunctionCallback
|
||||||
|
|
||||||
constructor(id:ODValidId, func:(manager:ODCheckerManager, functions:ODCheckerFunctionManager) => ODCheckerResult){
|
constructor(id:ODValidId, func:ODCheckerFunctionCallback){
|
||||||
super(id)
|
super(id)
|
||||||
this.func = func
|
this.func = func
|
||||||
}
|
}
|
||||||
@@ -1043,13 +1048,13 @@ export class ODCheckerEnabledObjectStructure extends ODCheckerStructure {
|
|||||||
*/
|
*/
|
||||||
export class ODCheckerCustomStructure_DiscordId extends ODCheckerStringStructure {
|
export class ODCheckerCustomStructure_DiscordId extends ODCheckerStringStructure {
|
||||||
/**The type of id (used in rendering) */
|
/**The type of id (used in rendering) */
|
||||||
readonly type: "role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message"
|
readonly type: ODDiscordIdType
|
||||||
/**Is this id allowed to be empty */
|
/**Is this id allowed to be empty */
|
||||||
readonly emptyAllowed: boolean
|
readonly emptyAllowed: boolean
|
||||||
/**Extra matches (value will also be valid when one of these options match) */
|
/**Extra matches (value will also be valid when one of these options match) */
|
||||||
readonly extraOptions: string[]
|
readonly extraOptions: string[]
|
||||||
|
|
||||||
constructor(id:ODValidId, type:"role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message", emptyAllowed:boolean, extraOptions:string[], options?:ODCheckerStringStructureOptions){
|
constructor(id:ODValidId, type:ODDiscordIdType, emptyAllowed:boolean, extraOptions:string[], options?:ODCheckerStringStructureOptions){
|
||||||
//add premade custom structure checker
|
//add premade custom structure checker
|
||||||
const newOptions = options ?? {}
|
const newOptions = options ?? {}
|
||||||
newOptions.custom = (checker,value,locationTrace,locationId,locationDocs) => {
|
newOptions.custom = (checker,value,locationTrace,locationId,locationDocs) => {
|
||||||
@@ -1083,11 +1088,11 @@ export class ODCheckerCustomStructure_DiscordId extends ODCheckerStringStructure
|
|||||||
*/
|
*/
|
||||||
export class ODCheckerCustomStructure_DiscordIdArray extends ODCheckerArrayStructure {
|
export class ODCheckerCustomStructure_DiscordIdArray extends ODCheckerArrayStructure {
|
||||||
/**The type of id (used in rendering) */
|
/**The type of id (used in rendering) */
|
||||||
readonly type: "role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message"
|
readonly type: ODDiscordIdType
|
||||||
/**Extra matches (value will also be valid when one of these options match) */
|
/**Extra matches (value will also be valid when one of these options match) */
|
||||||
readonly extraOptions: string[]
|
readonly extraOptions: string[]
|
||||||
|
|
||||||
constructor(id:ODValidId, type:"role"|"server"|"channel"|"category"|"user"|"member"|"interaction"|"message", extraOptions:string[], options?:ODCheckerArrayStructureOptions, idOptions?:ODCheckerStringStructureOptions){
|
constructor(id:ODValidId, type:ODDiscordIdType, extraOptions:string[], options?:ODCheckerArrayStructureOptions, idOptions?:ODCheckerStringStructureOptions){
|
||||||
//add premade custom structure checker
|
//add premade custom structure checker
|
||||||
const newOptions = options ?? {}
|
const newOptions = options ?? {}
|
||||||
newOptions.propertyChecker = new ODCheckerCustomStructure_DiscordId(id,type,false,extraOptions,idOptions)
|
newOptions.propertyChecker = new ODCheckerCustomStructure_DiscordId(id,type,false,extraOptions,idOptions)
|
||||||
|
|||||||
Reference in New Issue
Block a user