Fixed deprecation of HTML Transcripts interactions
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@discordjs/rest": "^2.4.2",
|
||||||
"@types/node": "^22.5.0",
|
"@types/node": "^22.5.0",
|
||||||
"ansis": "^2.3.0",
|
"ansis": "^2.3.0",
|
||||||
"discord.js": "^14.17.2",
|
"discord.js": "^14.17.2",
|
||||||
@@ -39,5 +40,9 @@
|
|||||||
"imports": {
|
"imports": {
|
||||||
"#opendiscord": "./dist/src/index.js",
|
"#opendiscord": "./dist/src/index.js",
|
||||||
"#opendiscord-types": "./dist/src/core/api/api.js"
|
"#opendiscord-types": "./dist/src/core/api/api.js"
|
||||||
|
},
|
||||||
|
"funding":{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/DJj123dj"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ export class ODMain {
|
|||||||
this.panels = new ODPanelManager(this.debug)
|
this.panels = new ODPanelManager(this.debug)
|
||||||
this.tickets = new ODTicketManager(this.debug,this.client)
|
this.tickets = new ODTicketManager(this.debug,this.client)
|
||||||
this.blacklist = new ODBlacklistManager(this.debug)
|
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)
|
this.roles = new ODRoleManager(this.debug)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId } from "./base"
|
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId } from "./base"
|
||||||
import * as discord from "discord.js"
|
import * as discord from "discord.js"
|
||||||
|
import {REST} from "@discordjs/rest"
|
||||||
import { ODConsoleWarningMessage, ODDebugger } from "./console"
|
import { ODConsoleWarningMessage, ODDebugger } from "./console"
|
||||||
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder"
|
import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder"
|
||||||
import { ODManualProgressBar } from "./progressbar"
|
import { ODManualProgressBar } from "./progressbar"
|
||||||
@@ -43,11 +44,21 @@ export class ODClientManager {
|
|||||||
partials: ODClientPartials[] = []
|
partials: ODClientPartials[] = []
|
||||||
/**List of required bot permissions. Add permissions to this list using the `onClientLoad` event. */
|
/**List of required bot permissions. Add permissions to this list using the `onClientLoad` event. */
|
||||||
permissions: ODClientPermissions[] = []
|
permissions: ODClientPermissions[] = []
|
||||||
/**The bot token, empty by default. */
|
/**The discord bot token, empty by default. */
|
||||||
token: string = ""
|
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! */
|
/**The discord.js `discord.Client`. Only use it when initiated! */
|
||||||
client: discord.Client<true> = new discord.Client({intents:[]}) //temporary client
|
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? */
|
/**Is the bot initiated? */
|
||||||
initiated: boolean = false
|
initiated: boolean = false
|
||||||
/**Is the bot logged in? */
|
/**Is the bot logged in? */
|
||||||
|
|||||||
@@ -5,15 +5,19 @@ import { ODId, ODManager, ODValidJsonType, ODValidId, ODManagerData, ODValidButt
|
|||||||
import { ODDebugger } from "../modules/console"
|
import { ODDebugger } from "../modules/console"
|
||||||
import { ODTicket, ODTicketManager } from "./ticket"
|
import { ODTicket, ODTicketManager } from "./ticket"
|
||||||
import { ODMessageBuildResult } from "../modules/builder"
|
import { ODMessageBuildResult } from "../modules/builder"
|
||||||
|
import { ODClientManager } from "../modules/client"
|
||||||
import * as discord from "discord.js"
|
import * as discord from "discord.js"
|
||||||
|
|
||||||
export class ODTranscriptManager extends ODManager<ODTranscriptCompiler<any>> {
|
export class ODTranscriptManager extends ODManager<ODTranscriptCompiler<any>> {
|
||||||
/**The manager responsible for collecting all messages in a channel. */
|
/**The manager responsible for collecting all messages in a channel. */
|
||||||
collector: ODTranscriptCollector
|
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")
|
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 {
|
export class ODTranscriptCollector {
|
||||||
/**Alias for the ticket manager. */
|
/**Alias for the ticket manager. */
|
||||||
#tickets: ODTicketManager
|
#tickets: ODTicketManager
|
||||||
|
/**Alias for the client manager. */
|
||||||
|
#client: ODClientManager
|
||||||
|
|
||||||
constructor(tickets:ODTicketManager){
|
constructor(tickets:ODTicketManager,client:ODClientManager){
|
||||||
this.#tickets = tickets
|
this.#tickets = tickets
|
||||||
|
this.#client = client
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Collect all messages from a given ticket channel. It may not include all messages depending on the ratelimit. */
|
/**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{}
|
}catch{}
|
||||||
|
|
||||||
//DEPRECATED WARNING!!! => msg.interaction might break in a future version of discord.js => required for slash command name
|
}else if (msg.interactionMetadata){
|
||||||
}else if (msg.interaction && msg.interaction.type == discord.InteractionType.ApplicationCommand){
|
try{
|
||||||
//slash command reply
|
//get slash command name from undocumented property in discord REST API
|
||||||
const member = await msg.guild.members.fetch(msg.interaction.user.id)
|
const restMsg = await this.#client.rest.get(discord.Routes.channelMessage(msg.channelId,msg.id)) as discord.APIMessage & {interaction_metadata:{name:string}}
|
||||||
reply = {
|
const commandName = restMsg.interaction_metadata.name ?? "unknown-command"
|
||||||
type:"interaction",
|
//slash command reply
|
||||||
name:msg.interaction.commandName,
|
const member = await msg.guild.members.fetch(msg.interactionMetadata.user.id)
|
||||||
user:this.#handleUserData(msg.interaction.user,member)
|
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("discord.js",true)
|
||||||
moduleInstalled("ansis",true)
|
moduleInstalled("ansis",true)
|
||||||
moduleInstalled("formatted-json-stringify",true)
|
moduleInstalled("formatted-json-stringify",true)
|
||||||
|
|||||||
Reference in New Issue
Block a user