Replaced #func() methods with TS: private func()

This commit is contained in:
DJj123dj
2026-05-03 22:04:38 +02:00
parent 10f5ae9d44
commit 4eb9331bf4
35 changed files with 342 additions and 273 deletions
+4 -4
View File
@@ -12,20 +12,20 @@ import * as api from "@open-discord-bots/framework/api"
*/
export class ODBlacklist extends api.ODManagerData {
/**The reason why this user got blacklisted. (optional) */
#reason: string|null
private rawReason: string|null
constructor(id:api.ODValidId,reason:string|null){
super(id)
this.#reason = reason
this.rawReason = reason
}
/**The reason why this user got blacklisted. (optional) */
set reason(reason:string|null) {
this.#reason = reason
this.rawReason = reason
this._change()
}
get reason(){
return this.#reason
return this.rawReason
}
}
+21 -24
View File
@@ -15,19 +15,16 @@ import { ODRoleUpdateMode } from "./role.js"
* All option types including: tickets, websites & reaction roles are stored here.
*/
export class ODOptionManager extends api.ODManager<ODOption> {
/**A reference to the Open Ticket debugger. */
#debug: api.ODDebugger
/**The option suffix manager used to generate channel suffixes for ticket names. */
suffix: ODOptionSuffixManager
constructor(debug:api.ODDebugger){
super(debug,"option")
this.#debug = debug
this.suffix = new ODOptionSuffixManager(debug)
}
add(data:ODOption, overwrite?:boolean): boolean {
data.useDebug(this.#debug,"option data")
data.useDebug(this.debug,"option data")
return super.add(data,overwrite)
}
}
@@ -110,20 +107,20 @@ export class ODOption extends api.ODManager<ODOptionData<api.ODValidJsonType>> {
*/
export class ODOptionData<DataType extends api.ODValidJsonType> extends api.ODManagerData {
/**The value of this property. */
#value: DataType
private rawValue: DataType
constructor(id:api.ODValidId, value:DataType){
super(id)
this.#value = value
this.rawValue = value
}
/**The value of this property. */
set value(value:DataType){
this.#value = value
this.rawValue = value
this._change()
}
get value(): DataType {
return this.#value
return this.rawValue
}
/**Refresh the database. Is only required to be used when updating `ODOptionData` with an object/array as value. */
refreshDatabase(){
@@ -355,7 +352,7 @@ export class ODOptionSuffixManager extends api.ODManager<ODOptionSuffix> {
const suffix = this.getAll().find((suffix) => suffix.option.id.value == option.id.value)
if (!suffix) return null
try{
const member = await this.#getMember(guild,user)
const member = await this.getMember(guild,user)
if (!member) return null
return await suffix.getSuffix(member)
}catch(err){
@@ -363,7 +360,7 @@ export class ODOptionSuffixManager extends api.ODManager<ODOptionSuffix> {
return null
}
}
async #getMember(guild:discord.Guild,user:discord.User){
private async getMember(guild:discord.Guild,user:discord.User){
try{
return await guild.members.fetch(user.id)
}catch{
@@ -447,11 +444,11 @@ export class ODOptionCounterDynamicSuffix extends ODOptionSuffix {
constructor(id:api.ODValidId, option:ODTicketOption, database:api.ODDatabase){
super(id,option)
this.database = database
this.#init()
this.init()
}
/**Initialize the database for this suffix. */
async #init(){
private async init(){
if (!await this.database.exists("opendiscord:option-suffix-counter",this.option.id.value)) await this.database.set("opendiscord:option-suffix-counter",this.option.id.value,0)
}
async getSuffix(member:discord.GuildMember): Promise<string> {
@@ -477,11 +474,11 @@ export class ODOptionCounterFixedSuffix extends ODOptionSuffix {
constructor(id:api.ODValidId, option:ODTicketOption, database:api.ODDatabase){
super(id,option)
this.database = database
this.#init()
this.init()
}
/**Initialize the database for this suffix. */
async #init(){
private async init(){
if (!await this.database.exists("opendiscord:option-suffix-counter",this.option.id.value)) await this.database.set("opendiscord:option-suffix-counter",this.option.id.value,0)
}
async getSuffix(member:discord.GuildMember): Promise<string> {
@@ -511,28 +508,28 @@ export class ODOptionRandomNumberSuffix extends ODOptionSuffix {
constructor(id:api.ODValidId, option:ODTicketOption, database:api.ODDatabase){
super(id,option)
this.database = database
this.#init()
this.init()
}
/**Initialize the database for this suffix. */
async #init(){
private async init(){
if (!await this.database.exists("opendiscord:option-suffix-history",this.option.id.value)) await this.database.set("opendiscord:option-suffix-history",this.option.id.value,[])
}
/**Get a unique number for this suffix. */
#generateUniqueValue(history:string[]): string {
protected generateUniqueValue(history:string[]): string {
const rawNumber = Math.round(Math.random()*1000).toString()
let number = rawNumber
if (rawNumber.length == 1) number = "000"+rawNumber
else if (rawNumber.length == 2) number = "00"+rawNumber
else if (rawNumber.length == 3) number = "0"+rawNumber
if (history.includes(number)) return this.#generateUniqueValue(history)
if (history.includes(number)) return this.generateUniqueValue(history)
else return number
}
async getSuffix(member:discord.GuildMember): Promise<string> {
const rawCurrentValues = await this.database.get("opendiscord:option-suffix-history",this.option.id.value)
const currentValues = ((Array.isArray(rawCurrentValues)) ? rawCurrentValues : []) as string[]
const newValue = this.#generateUniqueValue(currentValues)
const newValue = this.generateUniqueValue(currentValues)
currentValues.push(newValue)
if (currentValues.length > 50) currentValues.shift()
await this.database.set("opendiscord:option-suffix-history",this.option.id.value,currentValues)
@@ -554,23 +551,23 @@ export class ODOptionRandomHexSuffix extends ODOptionSuffix {
constructor(id:api.ODValidId, option:ODTicketOption, database:api.ODDatabase){
super(id,option)
this.database = database
this.#init()
this.init()
}
/**Initialize the database for this suffix. */
async #init(){
private async init(){
if (!await this.database.exists("opendiscord:option-suffix-history",this.option.id.value)) await this.database.set("opendiscord:option-suffix-history",this.option.id.value,[])
}
/**Get a unique hex-string for this suffix. */
#generateUniqueValue(history:string[]): string {
protected generateUniqueValue(history:string[]): string {
const hex = crypto.randomBytes(2).toString("hex")
if (history.includes(hex)) return this.#generateUniqueValue(history)
if (history.includes(hex)) return this.generateUniqueValue(history)
else return hex
}
async getSuffix(member:discord.GuildMember): Promise<string> {
const rawCurrentValues = await this.database.get("opendiscord:option-suffix-history",this.option.id.value)
const currentValues = ((Array.isArray(rawCurrentValues)) ? rawCurrentValues : []) as string[]
const newValue = this.#generateUniqueValue(currentValues)
const newValue = this.generateUniqueValue(currentValues)
currentValues.push(newValue)
if (currentValues.length > 50) currentValues.shift()
await this.database.set("opendiscord:option-suffix-history",this.option.id.value,currentValues)
+5 -9
View File
@@ -12,16 +12,12 @@ import { ODPanelsJsonConfig_PanelEmbedSettings } from "../mappings/config.js"
* Panels are not stored in the database and will be parsed from the config every startup.
*/
export class ODPanelManager extends api.ODManager<ODPanel> {
/**A reference to the Open Ticket debugger. */
#debug: api.ODDebugger
constructor(debug:api.ODDebugger){
super(debug,"option")
this.#debug = debug
}
add(data:ODPanel, overwrite?:boolean): boolean {
data.useDebug(this.#debug,"option data")
data.useDebug(this.debug,"option data")
return super.add(data,overwrite)
}
}
@@ -141,20 +137,20 @@ export class ODPanel extends api.ODManager<ODPanelData<api.ODValidJsonType>> {
*/
export class ODPanelData<DataType extends api.ODValidJsonType> extends api.ODManagerData {
/**The value of this property. */
#value: DataType
private rawValue: DataType
constructor(id:api.ODValidId, value:DataType){
super(id)
this.#value = value
this.rawValue = value
}
/**The value of this property. */
set value(value:DataType){
this.#value = value
this.rawValue = value
this._change()
}
get value(): DataType {
return this.#value
return this.rawValue
}
/**Refresh the database. Is only required to be used when updating `ODPanelData` with an object/array as value. */
refreshDatabase(){
-4
View File
@@ -30,12 +30,8 @@ export interface ODPriorityManagerIdMappings extends ODPriorityManagerIdConstrai
* Priorities levels can be changed/updated/translated by plugins to allow for more customisability.
*/
export class ODPriorityManager<IdList extends ODPriorityManagerIdConstraint = ODPriorityManagerIdConstraint> extends api.ODManager<ODPriorityLevel> {
/**A reference to the Open Ticket debugger. */
#debug: api.ODDebugger
constructor(debug:api.ODDebugger){
super(debug,"priority")
this.#debug = debug
}
/**Get an `ODPriorityLevel` from the priority level value. Returns a dummy value when the level doesn't exist. */
+5 -9
View File
@@ -11,16 +11,12 @@ import * as api from "@open-discord-bots/framework/api"
* Questions are not stored in the database and will be parsed from the config every startup.
*/
export class ODQuestionManager extends api.ODManager<ODQuestion> {
/**A reference to the Open Ticket debugger. */
#debug: api.ODDebugger
constructor(debug:api.ODDebugger){
super(debug,"question")
this.#debug = debug
}
add(data:ODQuestion, overwrite?:boolean): boolean {
data.useDebug(this.#debug,"question data")
data.useDebug(this.debug,"question data")
return super.add(data,overwrite)
}
}
@@ -103,20 +99,20 @@ export class ODQuestion extends api.ODManager<ODQuestionData<api.ODValidJsonType
*/
export class ODQuestionData<DataType extends api.ODValidJsonType> extends api.ODManagerData {
/**The value of this property. */
#value: DataType
private rawValue: DataType
constructor(id:api.ODValidId, value:DataType){
super(id)
this.#value = value
this.rawValue = value
}
/**The value of this property. */
set value(value:DataType){
this.#value = value
this.rawValue = value
this._change()
}
get value(): DataType {
return this.#value
return this.rawValue
}
/**Refresh the database. Is only required to be used when updating `ODQuestionData` with an object/array as value. */
refreshDatabase(){
+5 -9
View File
@@ -12,16 +12,12 @@ import * as discord from "discord.js"
* Roles are not stored in the database and will be parsed from the config every startup.
*/
export class ODRoleManager extends api.ODManager<ODRole> {
/**A reference to the Open Ticket debugger. */
#debug: api.ODDebugger
constructor(debug:api.ODDebugger){
super(debug,"role")
this.#debug = debug
}
add(data:ODRole, overwrite?:boolean): boolean {
data.useDebug(this.#debug,"role data")
data.useDebug(this.debug,"role data")
return super.add(data,overwrite)
}
}
@@ -130,20 +126,20 @@ export class ODRole extends api.ODManager<ODRoleData<api.ODValidJsonType>> {
*/
export class ODRoleData<DataType extends api.ODValidJsonType> extends api.ODManagerData {
/**The value of this property. */
#value: DataType
private rawValue: DataType
constructor(id:api.ODValidId, value:DataType){
super(id)
this.#value = value
this.rawValue = value
}
/**The value of this property. */
set value(value:DataType){
this.#value = value
this.rawValue = value
this._change()
}
get value(): DataType {
return this.#value
return this.rawValue
}
/**Refresh the database. Is only required to be used when updating `ODRoleData` with an object/array as value. */
refreshDatabase(){
+27 -30
View File
@@ -14,31 +14,28 @@ import * as discord from "discord.js"
*/
export class ODTicketManager extends api.ODManager<ODTicket> {
/**A reference to the main server of the bot */
#guild: discord.Guild|null = null
private guild: discord.Guild|null = null
/**A reference to the Open Ticket client manager. */
#client: api.ODClientManager
/**A reference to the Open Ticket debugger. */
#debug: api.ODDebugger
private client: api.ODClientManager
constructor(debug:api.ODDebugger, client:api.ODClientManager){
super(debug,"ticket")
this.#debug = debug
this.#client = client
this.client = client
}
add(data:ODTicket, overwrite?:boolean): boolean {
data.useDebug(this.#debug,"ticket data")
data.useDebug(this.debug,"ticket data")
return super.add(data,overwrite)
}
/**Use a specific guild in this class for fetching the channel*/
useGuild(guild:discord.Guild|null){
this.#guild = guild
this.guild = guild
}
/**Get the discord channel for a specific ticket. */
async getTicketChannel(ticket:ODTicket): Promise<discord.GuildTextBasedChannel|null> {
if (!this.#guild) return null
if (!this.guild) return null
try {
const channel = await this.#guild.channels.fetch(ticket.id.value)
const channel = await this.guild.channels.fetch(ticket.id.value)
if (!channel || !channel.isTextBased()) return null
return channel
}catch{
@@ -48,7 +45,7 @@ export class ODTicketManager extends api.ODManager<ODTicket> {
/**Get the main ticket message of a ticket channel when found. */
async getTicketMessage(ticket:ODTicket): Promise<discord.Message<true>|null> {
const msgId = ticket.get("opendiscord:ticket-message").value
if (!this.#guild || !msgId) return null
if (!this.guild || !msgId) return null
try {
const channel = await this.getTicketChannel(ticket)
if (!channel) return null
@@ -59,34 +56,34 @@ export class ODTicketManager extends api.ODManager<ODTicket> {
}
/**Shortcut for getting a discord.js user within a ticket. */
async getTicketUser(ticket:ODTicket, user:"creator"|"closer"|"claimer"|"pinner"): Promise<discord.User|null> {
if (!this.#guild) return null
if (!this.guild) return null
try {
if (user == "creator"){
const creatorId = ticket.get("opendiscord:opened-by").value
if (!creatorId) return null
else return (await this.#guild.client.users.fetch(creatorId))
else return (await this.guild.client.users.fetch(creatorId))
}else if (user == "closer"){
const closerId = ticket.get("opendiscord:closed-by").value
if (!closerId) return null
else return (await this.#guild.client.users.fetch(closerId))
else return (await this.guild.client.users.fetch(closerId))
}else if (user == "claimer"){
const claimerId = ticket.get("opendiscord:claimed-by").value
if (!claimerId) return null
else return (await this.#guild.client.users.fetch(claimerId))
else return (await this.guild.client.users.fetch(claimerId))
}else if (user == "pinner"){
const pinnerId = ticket.get("opendiscord:pinned-by").value
if (!pinnerId) return null
else return (await this.#guild.client.users.fetch(pinnerId))
else return (await this.guild.client.users.fetch(pinnerId))
}else return null
}catch {return null}
}
/**Shortcut for getting all users that are able to view a ticket. */
async getAllTicketParticipants(ticket:ODTicket): Promise<{user:discord.User,role:"creator"|"participant"|"admin"}[]|null> {
if (!this.#guild) return null
if (!this.guild) return null
const final: {user:discord.User,role:"creator"|"participant"|"admin"}[] = []
const channel = await this.getTicketChannel(ticket)
if (!channel) return null
@@ -94,7 +91,7 @@ export class ODTicketManager extends api.ODManager<ODTicket> {
//add creator
const creatorId = ticket.get("opendiscord:opened-by").value
if (creatorId){
const creator = await this.#client.fetchUser(creatorId)
const creator = await this.client.fetchUser(creatorId)
if (creator) final.push({user:creator,role:"creator"})
}
@@ -102,7 +99,7 @@ export class ODTicketManager extends api.ODManager<ODTicket> {
const participants = ticket.get("opendiscord:participants").value.filter((p) => p.type == "user")
for (const p of participants){
if (!final.find((u) => u.user.id == p.id)){
const participant = await this.#client.fetchUser(p.id)
const participant = await this.client.fetchUser(p.id)
if (participant) final.push({user:participant,role:"participant"})
}
}
@@ -110,7 +107,7 @@ export class ODTicketManager extends api.ODManager<ODTicket> {
//add admin roles
const roles = ticket.get("opendiscord:participants").value.filter((p) => p.type == "role")
for (const r of roles){
const role = await this.#client.fetchGuildRole(channel.guild,r.id)
const role = await this.client.fetchGuildRole(channel.guild,r.id)
if (role){
role.members.forEach((member) => {
if (final.find((u) => u.user.id == member.id)) return
@@ -201,25 +198,25 @@ export interface ODTicketIds {
export class ODTicket extends api.ODManager<ODTicketData<api.ODValidJsonType>> {
/**The id of this ticket. (discord channel id) */
id:api.ODId
/**The option related to this ticket. */
#option: ODTicketOption
/**The option this ticket is made of. */
private rawOption: ODTicketOption
constructor(id:api.ODValidId, option:ODTicketOption, data:ODTicketData<api.ODValidJsonType>[]){
super()
this.id = new api.ODId(id)
this.#option = option
this.rawOption = option
data.forEach((data) => {
this.add(data)
})
}
/**The option related to this ticket. */
/**The option this ticket is made of. */
set option(option:ODTicketOption){
this.#option = option
this.rawOption = option
this._change()
}
get option(){
return this.#option
return this.rawOption
}
/**Convert this ticket to a JSON object for storing this ticket in the database. */
@@ -275,20 +272,20 @@ export class ODTicket extends api.ODManager<ODTicketData<api.ODValidJsonType>> {
*/
export class ODTicketData<DataType extends api.ODValidJsonType> extends api.ODManagerData {
/**The value of this property. */
#value: DataType
private rawValue: DataType
constructor(id:api.ODValidId, value:DataType){
super(id)
this.#value = value
this.rawValue = value
}
/**The value of this property. */
set value(value:DataType){
this.#value = value
this.rawValue = value
this._change()
}
get value(): DataType {
return this.#value
return this.rawValue
}
/**Refresh the database. Is only required to be used when updating `ODTicketData` with an object/array as value. */
refreshDatabase(){
+28 -28
View File
@@ -30,11 +30,11 @@ export class ODTranscriptManager<IdList extends ODTranscriptManagerIdConstraint
/**The manager responsible for collecting all messages in a channel. */
collector: ODTranscriptCollector
/**Alias for the client manager. */
#client: api.ODClientManager
private client: api.ODClientManager
constructor(debug:api.ODDebugger, tickets:ODTicketManager, client:api.ODClientManager, permissions:api.ODPermissionManager){
super(debug,"transcript compiler")
this.#client = client
this.client = client
this.collector = new ODTranscriptCollector(tickets,client,permissions)
}
@@ -89,7 +89,7 @@ export interface ODTranscriptCompilerInitResult<InitData extends object|null> {
/**When not successfull, what was the reason? This will also be shown to the user. */
errorReason:string|null,
/**An optional message which will be sent while the transcript is being generated. */
pendingMessage:api.ODMessageBuildResult|null,
pendingMessage:api.ODMessageBuildResult|api.ODMessageComponentBuildResult|null,
/**An optional object containing data from the init() function which can be used in the compiler. */
initData:InitData,
}
@@ -119,15 +119,15 @@ export interface ODTranscriptCompilerCompileResult<Data extends object> {
*/
export interface ODTranscriptCompilerReadyResult {
/**The message to be sent in the specified channel in the server. */
channelMessage?:api.ODMessageBuildResult,
channelMessage?:api.ODMessageBuildResult|api.ODMessageComponentBuildResult,
/**The message to be sent to the DM of the ticket creator. */
creatorDmMessage?:api.ODMessageBuildResult,
creatorDmMessage?:api.ODMessageBuildResult|api.ODMessageComponentBuildResult,
/**The message to be sent to the DM of all participants. */
participantDmMessage?:api.ODMessageBuildResult,
participantDmMessage?:api.ODMessageBuildResult|api.ODMessageComponentBuildResult,
/**The message to be sent to the DM of all admins who actively participated in the ticket. */
activeAdminDmMessage?:api.ODMessageBuildResult,
activeAdminDmMessage?:api.ODMessageBuildResult|api.ODMessageComponentBuildResult,
/**The message to be sent to the DM of all admins who were assigned to this ticket. */
everyAdminDmMessage?:api.ODMessageBuildResult
everyAdminDmMessage?:api.ODMessageBuildResult|api.ODMessageComponentBuildResult
}
/**## ODTranscriptCompiler `class`
@@ -162,22 +162,22 @@ export class ODTranscriptCompiler<Data extends object,InitData extends (object|n
*/
export class ODTranscriptCollector {
/**Alias for the ticket manager. */
#tickets: ODTicketManager
private tickets: ODTicketManager
/**Alias for the client manager. */
#client: api.ODClientManager
private client: api.ODClientManager
/**Alias for the permissions manager. */
#permissions: api.ODPermissionManager
private permissions: api.ODPermissionManager
constructor(tickets:ODTicketManager,client:api.ODClientManager,permissions:api.ODPermissionManager){
this.#tickets = tickets
this.#client = client
this.#permissions = permissions
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. */
async collectAllMessages(ticket:ODTicket, include?:ODTranscriptCollectorIncludeSettings): Promise<discord.Message<true>[]|null> {
const newInclude: ODTranscriptCollectorIncludeSettings = include ?? {users:true,bots:true,client:true}
const channel = await this.#tickets.getTicketChannel(ticket)
const channel = await this.tickets.getTicketChannel(ticket)
if (!channel) return null
const final: discord.Message<true>[] = []
@@ -213,7 +213,7 @@ export class ODTranscriptCollector {
const {guild,channel,id,createdTimestamp} = msg
//create message author
const author = this.#handleUserData(msg.author,msg.member)
const author = this.handleUserData(msg.author,msg.member)
//create message type
let type: ODTranscriptMessageType = "default"
@@ -269,8 +269,8 @@ export class ODTranscriptCollector {
disabled:component.disabled,
type:"button",
label:component.label,
emoji:this.#handleComponentEmoji(msg,component.emoji),
color:this.#handleButtonComponentStyle(component.style),
emoji:this.handleComponentEmoji(msg,component.emoji),
color:this.handleButtonComponentStyle(component.style),
mode:(component.style == discord.ButtonStyle.Link) ? "url" : "button",
url:component.url
})
@@ -285,7 +285,7 @@ export class ODTranscriptCollector {
id:option.value,
label:option.label,
description:option.description ?? null,
emoji:this.#handleComponentEmoji(msg,option.emoji ?? null)
emoji:this.handleComponentEmoji(msg,option.emoji ?? null)
}
})
})
@@ -303,7 +303,7 @@ export class ODTranscriptCollector {
if (replyChannel && !replyChannel.isDMBased() && replyChannel.isTextBased()){
const replyMessage = await replyChannel.messages.fetch(msg.reference.messageId)
if (replyMessage){
const replyUser = this.#handleUserData(replyMessage.author,replyMessage.member)
const replyUser = this.handleUserData(replyMessage.author,replyMessage.member)
reply = {
type:"message",
@@ -320,7 +320,7 @@ export class ODTranscriptCollector {
}else if (msg.interactionMetadata){
try{
//get slash command name from undocumented property in discord REST API
const restMsg = await this.#client.rest.get(discord.Routes.channelMessage(msg.channelId,msg.id)) as discord.APIMessage & {interaction_metadata:{name:string}}
const restMsg = await this.client.rest.get(discord.Routes.channelMessage(msg.channelId,msg.id)) as discord.APIMessage & {interaction_metadata:{name:string}}
const commandName = restMsg.interaction_metadata.name ?? "unknown-command"
//slash command reply
let member: discord.GuildMember|null = null
@@ -330,7 +330,7 @@ export class ODTranscriptCollector {
reply = {
type:"interaction",
name:commandName,
user:this.#handleUserData(msg.interactionMetadata.user,member)
user:this.handleUserData(msg.interactionMetadata.user,member)
}
}catch(err){
process.emit("uncaughtException",err)
@@ -395,7 +395,7 @@ export class ODTranscriptCollector {
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 {
private handleComponentEmoji(message:discord.Message<true>, rawEmoji:discord.APIMessageComponentEmoji|null): ODTranscriptEmojiData|null {
if (!rawEmoji) return null
//return built-in emoji
if (rawEmoji.name) return {
@@ -418,14 +418,14 @@ export class ODTranscriptCollector {
}
}
/**Create the `ODValidButtonColor` from the discord.js button style. */
#handleButtonComponentStyle(style:discord.ButtonStyle): api.ODValidButtonColor {
private handleButtonComponentStyle(style:discord.ButtonStyle): api.ODValidButtonColor {
if (style == discord.ButtonStyle.Danger) return "red"
else if (style == discord.ButtonStyle.Success) return "green"
else if (style == discord.ButtonStyle.Primary) return "blue"
else return "gray"
}
/**Create the `ODTranscriptUserData` from a discord.js user. */
#handleUserData(user:discord.User, member?:discord.GuildMember|null): ODTranscriptUserData {
private handleUserData(user:discord.User, member?:discord.GuildMember|null): ODTranscriptUserData {
const userData: ODTranscriptUserData = {
id:user.id,
username:user.username,
@@ -450,10 +450,10 @@ export class ODTranscriptCollector {
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 (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))
const isAdmin = this.permissions.hasPermissions("support",await this.permissions.getPermissions(user,channel,guild))
if (isAdmin) adminMessages++
else userMessages++
}