Finished API comments
This commit is contained in:
@@ -55,23 +55,49 @@ export interface ODTranscriptCompilerInitResult {
|
|||||||
pendingMessage:ODMessageBuildResult|null
|
pendingMessage:ODMessageBuildResult|null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptCompilerCompileResult `interface`
|
||||||
|
* This is the result which is returned by the `compile()` function.
|
||||||
|
*/
|
||||||
export interface ODTranscriptCompilerCompileResult<Data extends object> {
|
export interface ODTranscriptCompilerCompileResult<Data extends object> {
|
||||||
|
/**The ticket this transcript is being created for. */
|
||||||
ticket:ODTicket,
|
ticket:ODTicket,
|
||||||
|
/**The channel this transcript is being created for. */
|
||||||
channel:discord.TextChannel,
|
channel:discord.TextChannel,
|
||||||
|
/**The user who created the transcript. */
|
||||||
user:discord.User
|
user:discord.User
|
||||||
|
/**Was the compilation successfull? */
|
||||||
success:boolean,
|
success:boolean,
|
||||||
|
/**When not successfull, what was the reason? This will also be shown to the user. */
|
||||||
errorReason:string|null,
|
errorReason:string|null,
|
||||||
|
/**A list of all messages sent in the ticket channel. */
|
||||||
messages:ODTranscriptMessageData[]|null,
|
messages:ODTranscriptMessageData[]|null,
|
||||||
|
/**The result returned by the `compiler()` function. Contains the transcript contents, url or something else. */
|
||||||
data:Data|null
|
data:Data|null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptCompilerReadyResult `interface`
|
||||||
|
* This is the result which is returned by the `ready()` function.
|
||||||
|
*/
|
||||||
export interface ODTranscriptCompilerReadyResult {
|
export interface ODTranscriptCompilerReadyResult {
|
||||||
|
/**The message to be sent in the specified channel in the server. */
|
||||||
channelMessage?:ODMessageBuildResult,
|
channelMessage?:ODMessageBuildResult,
|
||||||
|
/**The message to be sent to the DM of the ticket creator. */
|
||||||
creatorDmMessage?:ODMessageBuildResult,
|
creatorDmMessage?:ODMessageBuildResult,
|
||||||
|
/**The message to be sent to the DM of all participants. */
|
||||||
participantDmMessage?:ODMessageBuildResult,
|
participantDmMessage?:ODMessageBuildResult,
|
||||||
|
/**The message to be sent to the DM of all admins who actively participated in the ticket. */
|
||||||
activeAdminDmMessage?:ODMessageBuildResult,
|
activeAdminDmMessage?:ODMessageBuildResult,
|
||||||
|
/**The message to be sent to the DM of all admins who were assigned to this ticket. */
|
||||||
everyAdminDmMessage?:ODMessageBuildResult
|
everyAdminDmMessage?:ODMessageBuildResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptCompiler `class`
|
||||||
|
* This is an Open Ticket transcript compiler.
|
||||||
|
*
|
||||||
|
* This class manages all functions to generate a transcript.
|
||||||
|
*
|
||||||
|
* These functions should be defined when creating this compiler. Existing compilers already exist for html & text transcripts.
|
||||||
|
*/
|
||||||
export class ODTranscriptCompiler<Data extends object> extends ODManagerData {
|
export class ODTranscriptCompiler<Data extends object> extends ODManagerData {
|
||||||
/*Initialise the system every time a transcript is created. Returns optional "pending" message to display while the transcript is being compiled. */
|
/*Initialise the system every time a transcript is created. Returns optional "pending" message to display while the transcript is being compiled. */
|
||||||
init: ODTranscriptCompilerInitFunction|null
|
init: ODTranscriptCompilerInitFunction|null
|
||||||
@@ -126,6 +152,13 @@ export class ODTranscriptManager_Default extends ODTranscriptManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptCollector `class`
|
||||||
|
* This is an Open Ticket transcript collector.
|
||||||
|
*
|
||||||
|
* The only goal of this class is to collect & parse all messages from a ticket channel.
|
||||||
|
*
|
||||||
|
* It also contains utility functions for counting all messages, calculating file sizes & more!
|
||||||
|
*/
|
||||||
export class ODTranscriptCollector {
|
export class ODTranscriptCollector {
|
||||||
/**Alias for the ticket manager. */
|
/**Alias for the ticket manager. */
|
||||||
#tickets: ODTicketManager
|
#tickets: ODTicketManager
|
||||||
@@ -169,6 +202,7 @@ export class ODTranscriptCollector {
|
|||||||
if (!messages) return null
|
if (!messages) return null
|
||||||
return messages.length
|
return messages.length
|
||||||
}
|
}
|
||||||
|
/**Convert an array of discord messages to an array of `ODTranscriptMessageData`'s. This is used to simplify the process of the transcript compilers. */
|
||||||
async convertMessagesToTranscriptData(messages:discord.Message<true>[]): Promise<ODTranscriptMessageData[]> {
|
async convertMessagesToTranscriptData(messages:discord.Message<true>[]): Promise<ODTranscriptMessageData[]> {
|
||||||
const final: ODTranscriptMessageData[] = []
|
const final: ODTranscriptMessageData[] = []
|
||||||
for (const msg of messages){
|
for (const msg of messages){
|
||||||
@@ -401,6 +435,9 @@ export class ODTranscriptCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptCollectorIncludeSettings `interface`
|
||||||
|
* Additional settings for the `ODTranscriptCollector`
|
||||||
|
*/
|
||||||
export interface ODTranscriptCollectorIncludeSettings {
|
export interface ODTranscriptCollectorIncludeSettings {
|
||||||
/**Collect messages from normal discord users. */
|
/**Collect messages from normal discord users. */
|
||||||
users: boolean,
|
users: boolean,
|
||||||
@@ -410,6 +447,9 @@ export interface ODTranscriptCollectorIncludeSettings {
|
|||||||
client: boolean
|
client: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptMessageData `interface`
|
||||||
|
* A universal representatation of a discord message for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptMessageData {
|
export interface ODTranscriptMessageData {
|
||||||
/**The message author. */
|
/**The message author. */
|
||||||
author: ODTranscriptUserData,
|
author: ODTranscriptUserData,
|
||||||
@@ -439,8 +479,14 @@ export interface ODTranscriptMessageData {
|
|||||||
reactions: ODTranscriptReactionData[]
|
reactions: ODTranscriptReactionData[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptMessageType `type`
|
||||||
|
* A message type for the `ODTranscriptMessageData` interface.
|
||||||
|
*/
|
||||||
export type ODTranscriptMessageType = "default"|"important"|"ephemeral"|"pinned.message"|"welcome.message"|"boost.message"|"thread.message"
|
export type ODTranscriptMessageType = "default"|"important"|"ephemeral"|"pinned.message"|"welcome.message"|"boost.message"|"thread.message"
|
||||||
|
|
||||||
|
/**## ODTranscriptUserData `interface`
|
||||||
|
* A universal representatation of a discord user for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptUserData {
|
export interface ODTranscriptUserData {
|
||||||
/**The id of this user. */
|
/**The id of this user. */
|
||||||
id: string,
|
id: string,
|
||||||
@@ -456,6 +502,9 @@ export interface ODTranscriptUserData {
|
|||||||
color: discord.HexColorString
|
color: discord.HexColorString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptEmbedData `interface`
|
||||||
|
* A universal representatation of a discord embed for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptEmbedData {
|
export interface ODTranscriptEmbedData {
|
||||||
/**The title of this embed. */
|
/**The title of this embed. */
|
||||||
title: string|null,
|
title: string|null,
|
||||||
@@ -481,6 +530,9 @@ export interface ODTranscriptEmbedData {
|
|||||||
fields: ODTranscriptEmbedFieldData[]
|
fields: ODTranscriptEmbedFieldData[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptEmbedFieldData `interface`
|
||||||
|
* A universal representatation of a discord embed field for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptEmbedFieldData {
|
export interface ODTranscriptEmbedFieldData {
|
||||||
/**The name of this embed field. */
|
/**The name of this embed field. */
|
||||||
name: string,
|
name: string,
|
||||||
@@ -490,6 +542,9 @@ export interface ODTranscriptEmbedFieldData {
|
|||||||
inline: boolean
|
inline: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptFileData `interface`
|
||||||
|
* A universal representatation of a discord message attachment for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptFileData {
|
export interface ODTranscriptFileData {
|
||||||
/**The file type or extension. */
|
/**The file type or extension. */
|
||||||
type: string,
|
type: string,
|
||||||
@@ -507,11 +562,17 @@ export interface ODTranscriptFileData {
|
|||||||
alt: string|null
|
alt: string|null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptComponentRowData `interface`
|
||||||
|
* A universal representatation of a discord message action row for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptComponentRowData {
|
export interface ODTranscriptComponentRowData {
|
||||||
/**All components (buttons & dropdowns) present in this action row. */
|
/**All components (buttons & dropdowns) present in this action row. */
|
||||||
components: (ODTranscriptButtonComponentData|ODTranscriptDropdownComponentData)[]
|
components: (ODTranscriptButtonComponentData|ODTranscriptDropdownComponentData)[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptComponentData `interface`
|
||||||
|
* A universal representatation of a discord message action row component for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptComponentData {
|
export interface ODTranscriptComponentData {
|
||||||
/**The custom id of this component. */
|
/**The custom id of this component. */
|
||||||
id: string|null,
|
id: string|null,
|
||||||
@@ -521,6 +582,9 @@ export interface ODTranscriptComponentData {
|
|||||||
type: "button"|"dropdown"
|
type: "button"|"dropdown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptButtonComponentData `interface`
|
||||||
|
* A universal representatation of a discord message button for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptButtonComponentData extends ODTranscriptComponentData {
|
export interface ODTranscriptButtonComponentData extends ODTranscriptComponentData {
|
||||||
/**The type of this component. */
|
/**The type of this component. */
|
||||||
type: "button"
|
type: "button"
|
||||||
@@ -536,6 +600,9 @@ export interface ODTranscriptButtonComponentData extends ODTranscriptComponentDa
|
|||||||
url: string|null
|
url: string|null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptDropdownComponentData `interface`
|
||||||
|
* A universal representatation of a discord message dropdown for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptDropdownComponentData extends ODTranscriptComponentData {
|
export interface ODTranscriptDropdownComponentData extends ODTranscriptComponentData {
|
||||||
/**The type of this component. */
|
/**The type of this component. */
|
||||||
type: "dropdown"
|
type: "dropdown"
|
||||||
@@ -545,6 +612,9 @@ export interface ODTranscriptDropdownComponentData extends ODTranscriptComponent
|
|||||||
options: ODTranscriptDropdownComponentOptionData[]
|
options: ODTranscriptDropdownComponentOptionData[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptDropdownComponentOptionData `interface`
|
||||||
|
* A universal representatation of a discord message dropdown option for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptDropdownComponentOptionData {
|
export interface ODTranscriptDropdownComponentOptionData {
|
||||||
/**The custom id of this dropdown option. */
|
/**The custom id of this dropdown option. */
|
||||||
id: string,
|
id: string,
|
||||||
@@ -556,11 +626,17 @@ export interface ODTranscriptDropdownComponentOptionData {
|
|||||||
emoji: ODTranscriptEmojiData|null
|
emoji: ODTranscriptEmojiData|null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptReplyData `interface`
|
||||||
|
* A universal representatation of a discord reply/interaction for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptReplyData {
|
export interface ODTranscriptReplyData {
|
||||||
/**The type of reply. */
|
/**The type of reply. */
|
||||||
type: "interaction"|"message",
|
type: "interaction"|"message",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptReplyData `interface`
|
||||||
|
* A universal representatation of a discord interaction reply for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptInteractionReplyData extends ODTranscriptReplyData {
|
export interface ODTranscriptInteractionReplyData extends ODTranscriptReplyData {
|
||||||
/**The type of reply. */
|
/**The type of reply. */
|
||||||
type: "interaction",
|
type: "interaction",
|
||||||
@@ -570,6 +646,9 @@ export interface ODTranscriptInteractionReplyData extends ODTranscriptReplyData
|
|||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptReplyData `interface`
|
||||||
|
* A universal representatation of a discord message reply for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptMessageReplyData extends ODTranscriptReplyData {
|
export interface ODTranscriptMessageReplyData extends ODTranscriptReplyData {
|
||||||
/**The type of reply. */
|
/**The type of reply. */
|
||||||
type: "message",
|
type: "message",
|
||||||
@@ -585,6 +664,9 @@ export interface ODTranscriptMessageReplyData extends ODTranscriptReplyData {
|
|||||||
content: string|null
|
content: string|null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptEmojiData `interface`
|
||||||
|
* A universal representatation of a discord emoji for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptEmojiData {
|
export interface ODTranscriptEmojiData {
|
||||||
/**The id of this emoji. */
|
/**The id of this emoji. */
|
||||||
id: string|null,
|
id: string|null,
|
||||||
@@ -598,6 +680,9 @@ export interface ODTranscriptEmojiData {
|
|||||||
emoji: string,
|
emoji: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptReactionData `interface`
|
||||||
|
* A universal representatation of a discord message reaction for transcripts.
|
||||||
|
*/
|
||||||
export interface ODTranscriptReactionData extends ODTranscriptEmojiData {
|
export interface ODTranscriptReactionData extends ODTranscriptEmojiData {
|
||||||
/**The amount of emojis for this reaction. */
|
/**The amount of emojis for this reaction. */
|
||||||
amount: number,
|
amount: number,
|
||||||
@@ -605,6 +690,9 @@ export interface ODTranscriptReactionData extends ODTranscriptEmojiData {
|
|||||||
super: boolean
|
super: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptHtmlV2Data `interface`
|
||||||
|
* The structure of the data sent to the Open Ticket HTML Transcripts v2 API.
|
||||||
|
*/
|
||||||
export interface ODTranscriptHtmlV2Data {
|
export interface ODTranscriptHtmlV2Data {
|
||||||
version:"2",
|
version:"2",
|
||||||
otversion:string,
|
otversion:string,
|
||||||
@@ -792,6 +880,7 @@ export interface ODTranscriptHtmlV2Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}[],
|
}[],
|
||||||
|
//sadly enough, no premium yet :)
|
||||||
premium:{
|
premium:{
|
||||||
enabled:boolean,
|
enabled:boolean,
|
||||||
premiumToken:string,
|
premiumToken:string,
|
||||||
@@ -818,6 +907,9 @@ export interface ODTranscriptHtmlV2Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**## ODTranscriptHtmlV2Response `interface`
|
||||||
|
* The structure of the response received from the Open Ticket HTML Transcripts v2 API.
|
||||||
|
*/
|
||||||
export interface ODTranscriptHtmlV2Response {
|
export interface ODTranscriptHtmlV2Response {
|
||||||
status:"success"|"error",
|
status:"success"|"error",
|
||||||
id:string,
|
id:string,
|
||||||
|
|||||||
Reference in New Issue
Block a user