(v4.1) Added +/-10 Minor Features & Improvements
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { ODValidButtonColor, ODValidId } from "../modules/base"
|
||||
import * as discord from "discord.js"
|
||||
import { ODConfigManager, ODConfig, ODJsonConfig } from "../modules/config"
|
||||
import { ODClientActivityStatus, ODClientActivityType } from "../modules/client"
|
||||
import { ODClientActivityMode, ODClientActivityType } from "../modules/client"
|
||||
import { ODRoleUpdateMode } from "../openticket/role"
|
||||
|
||||
/** (CONTRIBUTOR GUIDE) HOW TO ADD NEW CONFIG VARIABLES?
|
||||
@@ -77,7 +77,7 @@ export interface ODJsonConfig_DefaultStatusType {
|
||||
/**The type of status (e.g. playing, listening, custom, ...) */
|
||||
type:Exclude<ODClientActivityType,false>,
|
||||
/**The mode/status of the bot (e.g. online, invisible, idle, do not disturb) */
|
||||
mode:ODClientActivityStatus
|
||||
mode:ODClientActivityMode
|
||||
/**The text for the status. */
|
||||
text:string,
|
||||
/**Additional text for the status. (visible below 'text') */
|
||||
|
||||
@@ -176,7 +176,7 @@ export class ODMain {
|
||||
this.panels = new ODPanelManager(this.debug)
|
||||
this.tickets = new ODTicketManager(this.debug,this.client)
|
||||
this.blacklist = new ODBlacklistManager(this.debug)
|
||||
this.transcripts = new ODTranscriptManager_Default(this.debug,this.tickets,this.client)
|
||||
this.transcripts = new ODTranscriptManager_Default(this.debug,this.tickets,this.client,this.permissions)
|
||||
this.roles = new ODRoleManager(this.debug)
|
||||
this.priorities = new ODPriorityManager_Default(this.debug)
|
||||
}
|
||||
|
||||
@@ -335,10 +335,10 @@ export class ODClientManager {
|
||||
* Possible activity types for the bot.
|
||||
*/
|
||||
export type ODClientActivityType = ("playing"|"listening"|"watching"|"custom"|false)
|
||||
/**## ODClientPermissions `type`
|
||||
/**## ODClientActivityMode `type`
|
||||
* Possible activity statuses for the bot.
|
||||
*/
|
||||
export type ODClientActivityStatus = ("online"|"invisible"|"idle"|"dnd")
|
||||
export type ODClientActivityMode = ("online"|"invisible"|"idle"|"dnd")
|
||||
|
||||
|
||||
/**## ODClientActivityManager `class`
|
||||
@@ -358,8 +358,10 @@ export class ODClientActivityManager {
|
||||
type: ODClientActivityType = false
|
||||
/**The current status text */
|
||||
text: string = ""
|
||||
/**The current status status */
|
||||
status: ODClientActivityStatus = "online"
|
||||
/**The current status mode */
|
||||
mode: ODClientActivityMode = "online"
|
||||
/**Additional state text */
|
||||
state: string = ""
|
||||
|
||||
/**The timer responsible for refreshing the status. Stop it using `clearInterval(interval)` */
|
||||
interval?: NodeJS.Timeout
|
||||
@@ -374,10 +376,11 @@ export class ODClientActivityManager {
|
||||
}
|
||||
|
||||
/**Update the status. When already initiated, it can take up to 10min to see the updated status in discord. */
|
||||
setStatus(type:ODClientActivityType, text:string, status:ODClientActivityStatus, forceUpdate?:boolean){
|
||||
setStatus(type:ODClientActivityType, text:string, mode:ODClientActivityMode, state:string, forceUpdate?:boolean){
|
||||
this.type = type
|
||||
this.text = text
|
||||
this.status = status
|
||||
this.mode = mode
|
||||
this.state = state
|
||||
if (forceUpdate) this.#updateClientActivity(this.type,this.text)
|
||||
}
|
||||
|
||||
@@ -404,10 +407,10 @@ export class ODClientActivityManager {
|
||||
this.manager.client.user.setPresence({
|
||||
activities:[{
|
||||
type:this.#getStatusTypeEnum(type),
|
||||
state:undefined,
|
||||
state:this.state ? this.state : undefined,
|
||||
name:text,
|
||||
}],
|
||||
status:this.status
|
||||
status:this.mode
|
||||
})
|
||||
}
|
||||
/**Get the enum that links to the correct type */
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ODTicket, ODTicketManager } from "./ticket"
|
||||
import { ODMessageBuildResult } from "../modules/builder"
|
||||
import { ODClientManager } from "../modules/client"
|
||||
import * as discord from "discord.js"
|
||||
import { ODPermissionManager_Default } from "#opendiscord-types"
|
||||
|
||||
/**## ODTranscriptManager `class`
|
||||
* This is an Open Ticket transcript manager.
|
||||
@@ -21,10 +22,10 @@ export class ODTranscriptManager extends ODManager<ODTranscriptCompiler<any,null
|
||||
/**Alias for the client manager. */
|
||||
#client: ODClientManager
|
||||
|
||||
constructor(debug:ODDebugger, tickets:ODTicketManager, client:ODClientManager){
|
||||
constructor(debug:ODDebugger, tickets:ODTicketManager, client:ODClientManager, permissions:ODPermissionManager_Default){
|
||||
super(debug,"transcript compiler")
|
||||
this.#client = client
|
||||
this.collector = new ODTranscriptCollector(tickets,client)
|
||||
this.collector = new ODTranscriptCollector(tickets,client,permissions)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,10 +167,13 @@ export class ODTranscriptCollector {
|
||||
#tickets: ODTicketManager
|
||||
/**Alias for the client manager. */
|
||||
#client: ODClientManager
|
||||
/**Alias for the permissions manager. */
|
||||
#permissions: ODPermissionManager_Default
|
||||
|
||||
constructor(tickets:ODTicketManager,client:ODClientManager){
|
||||
constructor(tickets:ODTicketManager,client:ODClientManager,permissions:ODPermissionManager_Default){
|
||||
this.#tickets = tickets
|
||||
this.#client = client
|
||||
this.#permissions = permissions
|
||||
}
|
||||
|
||||
/**Collect all messages from a given ticket channel. It may not include all messages depending on the ratelimit. */
|
||||
@@ -386,11 +390,11 @@ export class ODTranscriptCollector {
|
||||
}
|
||||
/**Calculate a human-readable file size. Used in transcripts. */
|
||||
calculateFileSize(bytes:number): {size:number, unit:"B"|"KB"|"MB"|"GB"|"TB"} {
|
||||
if (bytes >= 1000000000000) return {size:(Math.round((bytes/1000000000000)*100)/100),unit:"TB"}
|
||||
if (bytes >= 1000000000) return {size:(Math.round((bytes/1000000000)*100)/100),unit:"GB"}
|
||||
else if (bytes >= 1000000) return {size:(Math.round((bytes/1000000)*100)/100),unit:"MB"}
|
||||
else if (bytes >= 1000) return {size:(Math.round((bytes/1000)*100)/100),unit:"KB"}
|
||||
else return {size:bytes,unit:"B"}
|
||||
if (bytes < 1024) return {size:Math.round(bytes),unit:"B"}
|
||||
else if (bytes < 1024*1024) return {size:Math.round(bytes/1024),unit:"KB"}
|
||||
else if (bytes < 1024*1024*1024) return {size:Math.round(bytes/(1024*1024)),unit:"MB"}
|
||||
else if (bytes < 1024*1024*1024*1024) return {size:Math.round(bytes/(1024*1024*1024)),unit:"GB"}
|
||||
else return {size:Math.round(bytes/(1024*1024*1024*1024)),unit:"TB"}
|
||||
}
|
||||
/**Get the `ODTranscriptEmojiData` from a discord.js component emoji. */
|
||||
#handleComponentEmoji(message:discord.Message<true>, rawEmoji:discord.APIMessageComponentEmoji|null): ODTranscriptEmojiData|null {
|
||||
@@ -439,6 +443,25 @@ export class ODTranscriptCollector {
|
||||
|
||||
return userData
|
||||
}
|
||||
/**Analyse the ticket for the amount of messages users & admins have sent in the ticket. */
|
||||
async ticketUserMessagesAnalysis(ticket:ODTicket,guild:discord.Guild,channel:discord.GuildTextBasedChannel){
|
||||
const messages = await this.collectAllMessages(ticket,{bots:true,client:true,users:true})
|
||||
if (!messages) return null
|
||||
const parsedMessages = await this.convertMessagesToTranscriptData(messages)
|
||||
let userMessages = 0
|
||||
let adminMessages = 0
|
||||
|
||||
for (const msg of parsedMessages){
|
||||
if (msg.author.tag || msg.author.id == this.#client.client.user.id) continue
|
||||
const user = await this.#client.fetchUser(msg.author.id)
|
||||
if (!user) continue
|
||||
const isAdmin = this.#permissions.hasPermissions("support",await this.#permissions.getPermissions(user,channel,guild))
|
||||
if (isAdmin) adminMessages++
|
||||
else userMessages++
|
||||
}
|
||||
|
||||
return {userMessages,adminMessages,totalMessages:userMessages+adminMessages}
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODTranscriptCollectorIncludeSettings `interface`
|
||||
|
||||
@@ -226,7 +226,7 @@ async function quickSetupLogin(token:string): Promise<api.ODClientManager|null>
|
||||
return new Promise(async (resolve) => {
|
||||
try{
|
||||
client.readyListener = async () => {
|
||||
client.activity.setStatus("custom","Configuring Open Ticket...","idle",true)
|
||||
client.activity.setStatus("custom","Configuring Open Ticket...","idle","",true)
|
||||
resolve(client)
|
||||
}
|
||||
const success = await client.login(true)
|
||||
|
||||
Reference in New Issue
Block a user