Fixed deprecation of HTML Transcripts interactions
This commit is contained in:
@@ -173,7 +173,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.transcripts = new ODTranscriptManager_Default(this.debug,this.tickets,this.client)
|
||||
this.roles = new ODRoleManager(this.debug)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
///////////////////////////////////////
|
||||
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId } from "./base"
|
||||
import * as discord from "discord.js"
|
||||
import {REST} from "@discordjs/rest"
|
||||
import { ODConsoleWarningMessage, ODDebugger } from "./console"
|
||||
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder"
|
||||
import { ODManualProgressBar } from "./progressbar"
|
||||
@@ -43,11 +44,21 @@ export class ODClientManager {
|
||||
partials: ODClientPartials[] = []
|
||||
/**List of required bot permissions. Add permissions to this list using the `onClientLoad` event. */
|
||||
permissions: ODClientPermissions[] = []
|
||||
/**The bot token, empty by default. */
|
||||
token: string = ""
|
||||
/**The discord bot token, empty by default. */
|
||||
set token(value:string){
|
||||
this.#token = value
|
||||
this.rest.setToken(value)
|
||||
}
|
||||
get token(){
|
||||
return this.#token
|
||||
}
|
||||
/**The discord bot token. **DON'T USE THIS!!!** (use `ODClientManager.token` instead) */
|
||||
#token: string = ""
|
||||
|
||||
/**The discord.js `discord.Client`. Only use it when initiated! */
|
||||
client: discord.Client<true> = new discord.Client({intents:[]}) //temporary client
|
||||
/**The discord.js REST client. Used for stuff that discord.js can't handle :) */
|
||||
rest: discord.REST = new REST({version:"10"})
|
||||
/**Is the bot initiated? */
|
||||
initiated: boolean = false
|
||||
/**Is the bot logged in? */
|
||||
|
||||
@@ -5,15 +5,19 @@ import { ODId, ODManager, ODValidJsonType, ODValidId, ODManagerData, ODValidButt
|
||||
import { ODDebugger } from "../modules/console"
|
||||
import { ODTicket, ODTicketManager } from "./ticket"
|
||||
import { ODMessageBuildResult } from "../modules/builder"
|
||||
import { ODClientManager } from "../modules/client"
|
||||
import * as discord from "discord.js"
|
||||
|
||||
export class ODTranscriptManager extends ODManager<ODTranscriptCompiler<any>> {
|
||||
/**The manager responsible for collecting all messages in a channel. */
|
||||
collector: ODTranscriptCollector
|
||||
/**Alias for the client manager. */
|
||||
#client: ODClientManager
|
||||
|
||||
constructor(debug:ODDebugger, tickets:ODTicketManager){
|
||||
constructor(debug:ODDebugger, tickets:ODTicketManager, client:ODClientManager){
|
||||
super(debug,"transcript compiler")
|
||||
this.collector = new ODTranscriptCollector(tickets)
|
||||
this.#client = client
|
||||
this.collector = new ODTranscriptCollector(tickets,client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +105,12 @@ export class ODTranscriptManager_Default extends ODTranscriptManager {
|
||||
export class ODTranscriptCollector {
|
||||
/**Alias for the ticket manager. */
|
||||
#tickets: ODTicketManager
|
||||
/**Alias for the client manager. */
|
||||
#client: ODClientManager
|
||||
|
||||
constructor(tickets:ODTicketManager){
|
||||
constructor(tickets:ODTicketManager,client:ODClientManager){
|
||||
this.#tickets = tickets
|
||||
this.#client = client
|
||||
}
|
||||
|
||||
/**Collect all messages from a given ticket channel. It may not include all messages depending on the ratelimit. */
|
||||
@@ -247,14 +254,20 @@ export class ODTranscriptCollector {
|
||||
}
|
||||
}catch{}
|
||||
|
||||
//DEPRECATED WARNING!!! => msg.interaction might break in a future version of discord.js => required for slash command name
|
||||
}else if (msg.interaction && msg.interaction.type == discord.InteractionType.ApplicationCommand){
|
||||
//slash command reply
|
||||
const member = await msg.guild.members.fetch(msg.interaction.user.id)
|
||||
reply = {
|
||||
type:"interaction",
|
||||
name:msg.interaction.commandName,
|
||||
user:this.#handleUserData(msg.interaction.user,member)
|
||||
}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 commandName = restMsg.interaction_metadata.name ?? "unknown-command"
|
||||
//slash command reply
|
||||
const member = await msg.guild.members.fetch(msg.interactionMetadata.user.id)
|
||||
reply = {
|
||||
type:"interaction",
|
||||
name:commandName,
|
||||
user:this.#handleUserData(msg.interactionMetadata.user,member)
|
||||
}
|
||||
}catch(err){
|
||||
process.emit("uncaughtException",err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ const moduleInstalled = (id:string, throwError:boolean) => {
|
||||
}
|
||||
}
|
||||
|
||||
moduleInstalled("@discordjs/rest",true)
|
||||
moduleInstalled("discord.js",true)
|
||||
moduleInstalled("ansis",true)
|
||||
moduleInstalled("formatted-json-stringify",true)
|
||||
|
||||
Reference in New Issue
Block a user