(v4.2.0) Added 5 new question types
Added support for dropdown, radio select, checkbox select, file upload & text display question types.
This commit is contained in:
+196
-69
@@ -2,6 +2,8 @@
|
||||
//OPENTICKET OPTION MODULE
|
||||
///////////////////////////////////////
|
||||
import * as api from "@open-discord-bots/framework/api"
|
||||
import * as discord from "discord.js"
|
||||
import { ODQuestionsJsonConfig_BaseQuestion, ODQuestionsJsonConfig_DropdownChoice, ODQuestionsJsonConfig_RadioCheckboxChoice } from "../mappings/config.js"
|
||||
|
||||
/**## ODQuestionIdConstraint `type`
|
||||
* The constraint/layout for id mappings/interfaces of the `ODQuestion` class.
|
||||
@@ -14,9 +16,10 @@ export type ODQuestionIdConstraint = Record<string,ODQuestionData<api.ODValidJso
|
||||
*/
|
||||
export interface ODShortQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:name":ODQuestionData<string>,
|
||||
"opendiscord:description":ODQuestionData<string>,
|
||||
"opendiscord:required":ODQuestionData<boolean>,
|
||||
"opendiscord:placeholder":ODQuestionData<string>,
|
||||
|
||||
"opendiscord:placeholder":ODQuestionData<string>,
|
||||
"opendiscord:length-enabled":ODQuestionData<boolean>,
|
||||
"opendiscord:length-min":ODQuestionData<number>,
|
||||
"opendiscord:length-max":ODQuestionData<number>
|
||||
@@ -28,14 +31,77 @@ export interface ODShortQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
*/
|
||||
export interface ODParagraphQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:name":ODQuestionData<string>,
|
||||
"opendiscord:description":ODQuestionData<string>,
|
||||
"opendiscord:required":ODQuestionData<boolean>,
|
||||
"opendiscord:placeholder":ODQuestionData<string>,
|
||||
|
||||
"opendiscord:placeholder":ODQuestionData<string>,
|
||||
"opendiscord:length-enabled":ODQuestionData<boolean>,
|
||||
"opendiscord:length-min":ODQuestionData<number>,
|
||||
"opendiscord:length-max":ODQuestionData<number>
|
||||
}
|
||||
|
||||
/**## ODDropdownQuestionIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODDropdownQuestion` class in `opendiscord`.
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODDropdownQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:name":ODQuestionData<string>,
|
||||
"opendiscord:description":ODQuestionData<string>,
|
||||
"opendiscord:required":ODQuestionData<boolean>,
|
||||
|
||||
"opendiscord:placeholder":ODQuestionData<string>,
|
||||
"opendiscord:choices":ODQuestionData<ODQuestionsJsonConfig_DropdownChoice[]>
|
||||
}
|
||||
|
||||
/**## ODRadioSelectQuestionIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODRadioSelectQuestion` class in `opendiscord`.
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODRadioSelectQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:name":ODQuestionData<string>,
|
||||
"opendiscord:description":ODQuestionData<string>,
|
||||
"opendiscord:required":ODQuestionData<boolean>,
|
||||
|
||||
"opendiscord:choices":ODQuestionData<ODQuestionsJsonConfig_RadioCheckboxChoice[]>
|
||||
}
|
||||
|
||||
/**## ODCheckboxSelectQuestionIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODCheckboxSelectQuestion` class in `opendiscord`.
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODCheckboxSelectQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:name":ODQuestionData<string>,
|
||||
"opendiscord:description":ODQuestionData<string>,
|
||||
"opendiscord:required":ODQuestionData<boolean>,
|
||||
|
||||
"opendiscord:limits-enabled":ODQuestionData<boolean>,
|
||||
"opendiscord:limits-min":ODQuestionData<number>,
|
||||
"opendiscord:limits-max":ODQuestionData<number>
|
||||
"opendiscord:choices":ODQuestionData<ODQuestionsJsonConfig_RadioCheckboxChoice[]>
|
||||
}
|
||||
|
||||
/**## ODFileUploadQuestionIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODFileUploadQuestion` class in `opendiscord`.
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODFileUploadQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:name":ODQuestionData<string>,
|
||||
"opendiscord:description":ODQuestionData<string>,
|
||||
"opendiscord:required":ODQuestionData<boolean>,
|
||||
|
||||
"opendiscord:limits-enabled":ODQuestionData<boolean>,
|
||||
"opendiscord:limits-min":ODQuestionData<number>,
|
||||
"opendiscord:limits-max":ODQuestionData<number>
|
||||
}
|
||||
|
||||
/**## ODTextDisplayQuestionIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODTextDisplayQuestion` class in `opendiscord`.
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODTextDisplayQuestionIdMappings extends ODQuestionIdConstraint {
|
||||
"opendiscord:text-contents":ODQuestionData<string>
|
||||
}
|
||||
|
||||
/**## ODQuestionManager `class`
|
||||
* This is an Open Ticket question manager.
|
||||
*
|
||||
@@ -81,20 +147,19 @@ export interface ODQuestionJson {
|
||||
/**## ODQuestion `class`
|
||||
* This is an Open Ticket question.
|
||||
*
|
||||
* This class contains all data related to this question (parsed from the config).
|
||||
* This class contains all question data parsed from the config.
|
||||
*
|
||||
* Use `ODShortQuestion` or `ODParagraphQuestion` instead!
|
||||
* This is an abstract class. Use instances like `ODShortQuestion` or `ODParagraphQuestion` instead.
|
||||
*/
|
||||
export class ODQuestion extends api.ODManager<ODQuestionData<api.ODValidJsonType>> {
|
||||
export abstract class ODQuestion<IdList extends ODQuestionIdConstraint = ODQuestionIdConstraint> extends api.ODManager<ODQuestionData<api.ODValidJsonType>> {
|
||||
/**The id of this question. (from the config) */
|
||||
id:api.ODId
|
||||
/**The type of this question (e.g. `opendiscord:short` or `opendiscord:paragraph`) */
|
||||
type: string
|
||||
abstract readonly type: string
|
||||
|
||||
constructor(id:api.ODValidId, type:string, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super()
|
||||
this.id = new api.ODId(id)
|
||||
this.type = type
|
||||
data.forEach((data) => {
|
||||
this.add(data)
|
||||
})
|
||||
@@ -117,9 +182,25 @@ export class ODQuestion extends api.ODManager<ODQuestionData<api.ODValidJsonType
|
||||
}
|
||||
}
|
||||
|
||||
/**Create a question from a JSON object in the database. */
|
||||
static fromJson(json:ODQuestionJson): ODQuestion {
|
||||
return new ODQuestion(json.id,json.type,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
get<QuestionId extends keyof api.ODNoGeneric<IdList>>(id:QuestionId): IdList[QuestionId]
|
||||
get(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null
|
||||
|
||||
get(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null {
|
||||
return super.get(id)
|
||||
}
|
||||
|
||||
remove<QuestionId extends keyof api.ODNoGeneric<IdList>>(id:QuestionId): IdList[QuestionId]
|
||||
remove(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null
|
||||
|
||||
remove(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null {
|
||||
return super.remove(id)
|
||||
}
|
||||
|
||||
exists(id:keyof api.ODNoGeneric<IdList>): boolean
|
||||
exists(id:api.ODValidId): boolean
|
||||
|
||||
exists(id:api.ODValidId): boolean {
|
||||
return super.exists(id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,40 +234,36 @@ export class ODQuestionData<DataType extends api.ODValidJsonType> extends api.OD
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODQuestionAnswer `type`
|
||||
* A question answer stored in the database.
|
||||
*/
|
||||
export type ODQuestionAnswer = {
|
||||
id:string,
|
||||
name:string,
|
||||
type:Exclude<ODQuestionsJsonConfig_BaseQuestion["type"],"text-display"|"file-upload">,
|
||||
value:string|null
|
||||
}|{
|
||||
id:string,
|
||||
name:string,
|
||||
type:"file-upload",
|
||||
files:{
|
||||
id:string,
|
||||
url:string,
|
||||
name:string,
|
||||
title:string|null,
|
||||
description:string|null,
|
||||
contentType:string|null,
|
||||
}[]
|
||||
}
|
||||
|
||||
/**## ODShortQuestion `class`
|
||||
* This is an Open Ticket short question.
|
||||
*
|
||||
* This class contains all data related to an Open Ticket short question (parsed from the config).
|
||||
*
|
||||
* Use this question in an option to add a short text field to the modal!
|
||||
* An Open Ticket short question. It contains all config properties of the short question type.
|
||||
*/
|
||||
export class ODShortQuestion extends ODQuestion {
|
||||
type: "opendiscord:short" = "opendiscord:short"
|
||||
export class ODShortQuestion extends ODQuestion<ODShortQuestionIdMappings> {
|
||||
readonly type: "opendiscord:short" = "opendiscord:short"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,"opendiscord:short",data)
|
||||
}
|
||||
|
||||
get<QuestionId extends keyof api.ODNoGeneric<ODShortQuestionIdMappings>>(id:QuestionId): ODShortQuestionIdMappings[QuestionId]
|
||||
get(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null
|
||||
|
||||
get(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null {
|
||||
return super.get(id)
|
||||
}
|
||||
|
||||
remove<QuestionId extends keyof api.ODNoGeneric<ODShortQuestionIdMappings>>(id:QuestionId): ODShortQuestionIdMappings[QuestionId]
|
||||
remove(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null
|
||||
|
||||
remove(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null {
|
||||
return super.remove(id)
|
||||
}
|
||||
|
||||
exists(id:keyof api.ODNoGeneric<ODShortQuestionIdMappings>): boolean
|
||||
exists(id:api.ODValidId): boolean
|
||||
|
||||
exists(id:api.ODValidId): boolean {
|
||||
return super.exists(id)
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODShortQuestion {
|
||||
@@ -195,41 +272,91 @@ export class ODShortQuestion extends ODQuestion {
|
||||
}
|
||||
|
||||
/**## ODParagraphQuestion `class`
|
||||
* This is an Open Ticket paragraph question.
|
||||
*
|
||||
* This class contains all data related to an Open Ticket paragraph question (parsed from the config).
|
||||
*
|
||||
* Use this question in an option to add a paragraph text field to the modal!
|
||||
* An Open Ticket paragraph question. It contains all config properties of the paragraph question type.
|
||||
*/
|
||||
export class ODParagraphQuestion extends ODQuestion {
|
||||
type: "opendiscord:paragraph" = "opendiscord:paragraph"
|
||||
export class ODParagraphQuestion extends ODQuestion<ODParagraphQuestionIdMappings> {
|
||||
readonly type: "opendiscord:paragraph" = "opendiscord:paragraph"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,"opendiscord:paragraph",data)
|
||||
}
|
||||
|
||||
get<QuestionId extends keyof api.ODNoGeneric<ODParagraphQuestionIdMappings>>(id:QuestionId): ODParagraphQuestionIdMappings[QuestionId]
|
||||
get(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null
|
||||
|
||||
get(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null {
|
||||
return super.get(id)
|
||||
}
|
||||
|
||||
remove<QuestionId extends keyof api.ODNoGeneric<ODParagraphQuestionIdMappings>>(id:QuestionId): ODParagraphQuestionIdMappings[QuestionId]
|
||||
remove(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null
|
||||
|
||||
remove(id:api.ODValidId): ODQuestionData<api.ODValidJsonType>|null {
|
||||
return super.remove(id)
|
||||
}
|
||||
|
||||
exists(id:keyof api.ODNoGeneric<ODParagraphQuestionIdMappings>): boolean
|
||||
exists(id:api.ODValidId): boolean
|
||||
|
||||
exists(id:api.ODValidId): boolean {
|
||||
return super.exists(id)
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODParagraphQuestion {
|
||||
return new ODParagraphQuestion(json.id,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODDropdownQuestion `class`
|
||||
* An Open Ticket dropdown question. It contains all config properties of the dropdown question type.
|
||||
*/
|
||||
export class ODDropdownQuestion extends ODQuestion<ODDropdownQuestionIdMappings> {
|
||||
readonly type: "opendiscord:dropdown" = "opendiscord:dropdown"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODDropdownQuestion {
|
||||
return new ODDropdownQuestion(json.id,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODRadioSelectQuestion `class`
|
||||
* An Open Ticket radio-select question. It contains all config properties of the radio-select question type.
|
||||
*/
|
||||
export class ODRadioSelectQuestion extends ODQuestion<ODRadioSelectQuestionIdMappings> {
|
||||
readonly type: "opendiscord:radio-select" = "opendiscord:radio-select"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODRadioSelectQuestion {
|
||||
return new ODRadioSelectQuestion(json.id,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODCheckboxSelectQuestion `class`
|
||||
* An Open Ticket checkbox-select question. It contains all config properties of the checkbox-select question type.
|
||||
*/
|
||||
export class ODCheckboxSelectQuestion extends ODQuestion<ODCheckboxSelectQuestionIdMappings> {
|
||||
readonly type: "opendiscord:checkbox-select" = "opendiscord:checkbox-select"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODCheckboxSelectQuestion {
|
||||
return new ODCheckboxSelectQuestion(json.id,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODFileUploadQuestion `class`
|
||||
* An Open Ticket file-upload question. It contains all config properties of the file-upload question type.
|
||||
*/
|
||||
export class ODFileUploadQuestion extends ODQuestion<ODFileUploadQuestionIdMappings> {
|
||||
readonly type: "opendiscord:file-upload" = "opendiscord:file-upload"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODFileUploadQuestion {
|
||||
return new ODFileUploadQuestion(json.id,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODTextDisplayQuestion `class`
|
||||
* An Open Ticket text-display question. It contains all config properties of the text-display question type.
|
||||
*/
|
||||
export class ODTextDisplayQuestion extends ODQuestion<ODTextDisplayQuestionIdMappings> {
|
||||
readonly type: "opendiscord:text-display" = "opendiscord:text-display"
|
||||
|
||||
constructor(id:api.ODValidId, data:ODQuestionData<api.ODValidJsonType>[]){
|
||||
super(id,data)
|
||||
}
|
||||
|
||||
static fromJson(json: ODQuestionJson): ODTextDisplayQuestion {
|
||||
return new ODTextDisplayQuestion(json.id,json.data.map((data) => new ODQuestionData(data.id,data.value)))
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
import * as api from "@open-discord-bots/framework/api"
|
||||
import { ODTicketOption } from "./option.js"
|
||||
import * as discord from "discord.js"
|
||||
import { ODQuestionAnswer } from "./question.js"
|
||||
|
||||
/**## ODTicketIdConstraint `type`
|
||||
* The constraint/layout for id mappings/interfaces of the `ODTicket` class.
|
||||
@@ -48,7 +49,7 @@ export interface ODTicketIdMappings extends ODTicketIdConstraint {
|
||||
"opendiscord:autodelete-enabled":ODTicketData<boolean>,
|
||||
"opendiscord:autodelete-days":ODTicketData<number>,
|
||||
|
||||
"opendiscord:answers":ODTicketData<{id:string,name:string,type:"short"|"paragraph",value:string|null}[]>,
|
||||
"opendiscord:answers":ODTicketData<ODQuestionAnswer[]>,
|
||||
"opendiscord:priority":ODTicketData<number>,
|
||||
"opendiscord:topic":ODTicketData<string>,
|
||||
"opendiscord:message-sent":ODTicketData<boolean>,
|
||||
|
||||
@@ -1411,6 +1411,19 @@ async function saveQuickSetupConfig(){
|
||||
{title:"Choice D",description:"Fear",selectedByDefault:false}
|
||||
]
|
||||
},
|
||||
{
|
||||
id:"example-question-6",
|
||||
name:"Example Question 6",
|
||||
description:"This is a file upload question.",
|
||||
type:"file-upload",
|
||||
required:true,
|
||||
|
||||
limits:{
|
||||
enabled:false,
|
||||
min:0,
|
||||
max:1
|
||||
}
|
||||
},
|
||||
{
|
||||
id:"example-text-display",
|
||||
type:"text-display",
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ODTicket, ODTicketClearFilter } from "../api/ticket.js"
|
||||
import { ODTranscriptCompiler, ODTranscriptCompilerCompileResult } from "../api/transcript.js"
|
||||
import { ODRole, ODRoleUpdateMode, ODRoleUpdateResult } from "../api/role.js"
|
||||
import { ODPriorityLevel } from "../api/priority.js"
|
||||
import { ODQuestionAnswer } from "../api/question.js"
|
||||
|
||||
/**## ODActionManagerIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODActionManager` class in `opendiscord`.
|
||||
@@ -28,7 +29,7 @@ export interface ODActionManagerIdMappings extends api.ODActionManagerIdConstrai
|
||||
},
|
||||
"opendiscord:create-ticket":{
|
||||
origin:"panel-button"|"panel-dropdown"|"slash"|"text"|"other",
|
||||
params:{guild:discord.Guild,user:discord.User,option:ODTicketOption,answers:{id:string,name:string,type:"short"|"paragraph",value:string|null}[]},
|
||||
params:{guild:discord.Guild,user:discord.User,option:ODTicketOption,answers:ODQuestionAnswer[]},
|
||||
result:{channel:discord.GuildTextBasedChannel,ticket:ODTicket},
|
||||
workers:"opendiscord:create-ticket"|"opendiscord:send-ticket-message"|"opendiscord:discord-logs"|"opendiscord:logs"
|
||||
},
|
||||
|
||||
@@ -235,14 +235,7 @@ export interface ODMessageManagerIdMappings extends api.ODMessageManagerIdConstr
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODModalManagerIdMappings extends api.ODModalManagerIdConstraint {
|
||||
"opendiscord:ticket-questions":{origin:"panel-button"|"panel-dropdown"|"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,option:ODTicketOption},workers:"opendiscord:ticket-questions"}
|
||||
"opendiscord:close-ticket-reason":{origin:"ticket-message"|"reopen-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:close-ticket-reason"}
|
||||
"opendiscord:reopen-ticket-reason":{origin:"ticket-message"|"close-message"|"autoclose-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:reopen-ticket-reason"}
|
||||
"opendiscord:delete-ticket-reason":{origin:"ticket-message"|"reopen-message"|"close-message"|"autoclose-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:delete-ticket-reason"}
|
||||
"opendiscord:claim-ticket-reason":{origin:"ticket-message"|"unclaim-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:claim-ticket-reason"}
|
||||
"opendiscord:unclaim-ticket-reason":{origin:"ticket-message"|"claim-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:unclaim-ticket-reason"}
|
||||
"opendiscord:pin-ticket-reason":{origin:"ticket-message"|"unpin-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:pin-ticket-reason"}
|
||||
"opendiscord:unpin-ticket-reason":{origin:"ticket-message"|"pin-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:unpin-ticket-reason"}
|
||||
//Deprecated, moved to ODModalComponentManagerIdMappings
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
///////////////////////////////////////
|
||||
import * as api from "@open-discord-bots/framework/api"
|
||||
import * as discord from "discord.js"
|
||||
import { ODTicketOption } from "../api/option.js"
|
||||
import { ODTicket } from "../api/ticket.js"
|
||||
|
||||
/**## ODSharedComponentManagerIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODSharedComponentManager` class in `opendiscord`.
|
||||
@@ -25,7 +27,14 @@ export interface ODMessageComponentManagerIdMappings extends api.ODComponentMana
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODModalComponentManagerIdMappings extends api.ODComponentManagerIdConstraint {
|
||||
//"opendiscord:example-modal":{origin:"slash"|"text"|"other",params:{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User},workers:"opendiscord:example-modal"},
|
||||
"opendiscord:ticket-questions":{origin:"panel-button"|"panel-dropdown"|"slash"|"text"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,option:ODTicketOption},workers:"opendiscord:ticket-questions"},
|
||||
"opendiscord:close-ticket-reason":{origin:"ticket-message"|"reopen-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:close-ticket-reason"}
|
||||
"opendiscord:reopen-ticket-reason":{origin:"ticket-message"|"close-message"|"autoclose-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:reopen-ticket-reason"}
|
||||
"opendiscord:delete-ticket-reason":{origin:"ticket-message"|"reopen-message"|"close-message"|"autoclose-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:delete-ticket-reason"}
|
||||
"opendiscord:claim-ticket-reason":{origin:"ticket-message"|"unclaim-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:claim-ticket-reason"}
|
||||
"opendiscord:unclaim-ticket-reason":{origin:"ticket-message"|"claim-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:unclaim-ticket-reason"}
|
||||
"opendiscord:pin-ticket-reason":{origin:"ticket-message"|"unpin-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:pin-ticket-reason"}
|
||||
"opendiscord:unpin-ticket-reason":{origin:"ticket-message"|"pin-message"|"other",params:{guild:discord.Guild,channel:discord.TextBasedChannel,user:discord.User,ticket:ODTicket,message:discord.Message},workers:"opendiscord:unpin-ticket-reason"}
|
||||
}
|
||||
|
||||
/**## ODComponentModifierManagerIdMappings `interface`
|
||||
|
||||
@@ -619,6 +619,18 @@ export interface ODQuestionsJsonConfig_CheckboxLimits {
|
||||
max:number
|
||||
}
|
||||
|
||||
/**## ODQuestionsJsonConfig_FileUploadLimits `interface`
|
||||
* Verify the amount of uploaded files in a question.
|
||||
*/
|
||||
export interface ODQuestionsJsonConfig_FileUploadLimits {
|
||||
/**Enable file limits. */
|
||||
enabled:boolean,
|
||||
/**The minimum amount of uploaded files. */
|
||||
min:number,
|
||||
/**The maximum amount of uploaded files. */
|
||||
max:number
|
||||
}
|
||||
|
||||
/**## ODQuestionsJsonConfig_DropdownChoice `interface`
|
||||
* A dropdown choice used in `ODQuestionsJsonConfig_DropdownQuestion`
|
||||
*/
|
||||
@@ -654,7 +666,7 @@ export interface ODQuestionsJsonConfig_BaseQuestion {
|
||||
/**The description of this question. (Leave empty for none) */
|
||||
description:string,
|
||||
/**The type of this question. */
|
||||
type:"short"|"paragraph"|"text-display"|"dropdown"|"radio-select"|"checkbox-select",
|
||||
type:"short"|"paragraph"|"text-display"|"dropdown"|"radio-select"|"checkbox-select"|"file-upload",
|
||||
/**Is this question required? */
|
||||
required:boolean,
|
||||
}
|
||||
@@ -662,9 +674,7 @@ export interface ODQuestionsJsonConfig_BaseQuestion {
|
||||
/**## ODQuestionsJsonConfig_TextDisplayQuestion `interface`
|
||||
* All properties for a text-display in the `questions.jsonc` config!
|
||||
*/
|
||||
export interface ODQuestionsJsonConfig_TextDisplayQuestion {
|
||||
/**The id of this text-display. */
|
||||
id:string,
|
||||
export interface ODQuestionsJsonConfig_TextDisplayQuestion extends Omit<ODQuestionsJsonConfig_BaseQuestion,"name"|"description"|"required"> {
|
||||
/**The type of this question. */
|
||||
type:"text-display",
|
||||
/**The text contents to show in the modal. */
|
||||
@@ -724,6 +734,15 @@ export interface ODQuestionsJsonConfig_CheckboxSelectQuestion extends ODQuestion
|
||||
choices:ODQuestionsJsonConfig_RadioCheckboxChoice[]
|
||||
}
|
||||
|
||||
/**## ODQuestionsJsonConfig_FileUploadQuestion `interface`
|
||||
* All properties for checkbox select questions in the `questions.jsonc` config!
|
||||
*/
|
||||
export interface ODQuestionsJsonConfig_FileUploadQuestion extends ODQuestionsJsonConfig_BaseQuestion {
|
||||
type:"file-upload",
|
||||
/**Verify the amount of uploaded files (minimum/maximum). */
|
||||
limits:ODQuestionsJsonConfig_FileUploadLimits
|
||||
}
|
||||
|
||||
/**## ODQuestionsJsonConfig_QuestionsData `type`
|
||||
* All contents of the `questions.jsonc` config file.
|
||||
*/
|
||||
@@ -733,7 +752,8 @@ export type ODQuestionsJsonConfig_QuestionsData = (
|
||||
ODQuestionsJsonConfig_TextDisplayQuestion|
|
||||
ODQuestionsJsonConfig_DropdownQuestion|
|
||||
ODQuestionsJsonConfig_RadioSelectQuestion|
|
||||
ODQuestionsJsonConfig_CheckboxSelectQuestion
|
||||
ODQuestionsJsonConfig_CheckboxSelectQuestion|
|
||||
ODQuestionsJsonConfig_FileUploadQuestion
|
||||
)[]
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
@@ -311,6 +311,19 @@ export const migrations = [
|
||||
{title:"Choice D",description:"Fear",selectedByDefault:false}
|
||||
]
|
||||
},
|
||||
{
|
||||
id:"example-file-upload",
|
||||
name:"Example File Upload",
|
||||
description:"With this question type, users can upload one or multiple files.",
|
||||
type:"file-upload",
|
||||
required:true,
|
||||
|
||||
limits:{
|
||||
enabled:false,
|
||||
min:0,
|
||||
max:1
|
||||
}
|
||||
},
|
||||
{
|
||||
id:"example-text-display-question",
|
||||
type:"text-display",
|
||||
|
||||
Reference in New Issue
Block a user