Implemented ODStates (Message States)
This commit is contained in:
@@ -135,7 +135,7 @@ export const registerActions = async () => {
|
||||
|
||||
//send channel message
|
||||
if (transcriptConfig.data.general.enableChannel && channelMessage){
|
||||
if (instance.pendingMessage && instance.pendingMessage.message && instance.pendingMessage.success){
|
||||
if (instance.pendingMessage && instance.pendingMessage.success){
|
||||
//edit "pending" message to be the "ready" message
|
||||
instance.pendingMessage.message.edit(utilities.getMessageFromBuildResult(channelMessage,"message"))
|
||||
}else{
|
||||
|
||||
@@ -25,6 +25,7 @@ export * from "./mappings/progressbar.js"
|
||||
export * from "./mappings/responder.js"
|
||||
export * from "./mappings/session.js"
|
||||
export * from "./mappings/startscreen.js"
|
||||
export * from "./mappings/state.js"
|
||||
export * from "./mappings/statistic.js"
|
||||
export * from "./mappings/verifybar.js"
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ export class ODOpenTicketMain extends api.ODMain {
|
||||
declare statistics: api.ODMappedStatisticManager
|
||||
declare code: api.ODMappedCodeManager
|
||||
declare posts: api.ODMappedPostManager
|
||||
declare states: api.ODMappedStateManager
|
||||
|
||||
declare client: api.ODMappedClientManager
|
||||
declare livestatus: api.ODMappedLiveStatusManager
|
||||
@@ -98,6 +99,7 @@ export class ODOpenTicketMain extends api.ODMain {
|
||||
statistics:new api.ODMappedStatisticManager(debug),
|
||||
code:new api.ODMappedCodeManager(debug),
|
||||
posts:new api.ODMappedPostManager(debug),
|
||||
states:new api.ODMappedStateManager(debug),
|
||||
|
||||
sharedFuses:utilities.sharedFuses,
|
||||
env:new api.ODEnvHelper(),
|
||||
|
||||
@@ -29,6 +29,7 @@ import { ODMappedStartScreenManager } from "./startscreen.js"
|
||||
import { ODMappedLiveStatusManager } from "./console.js"
|
||||
import { ODMappedProgressBarManager, ODMappedProgressBarRendererManager } from "./progressbar.js"
|
||||
import { ODMappedComponentManager, ODMappedMessageComponentManager, ODMappedModalComponentManager, ODMappedSharedComponentManager } from "./component.js"
|
||||
import { ODMappedStateManager } from "./state.js"
|
||||
|
||||
//OPEN TICKET MAPPINGSS
|
||||
import { ODOptionManager, ODTicketOption } from "../api/option.js"
|
||||
@@ -139,6 +140,12 @@ export interface ODEventManagerIdMappings extends api.ODEventManagerIdConstraint
|
||||
"onTextCommandLoad": api.ODEvent<(text:ODMappedTextCommandManager, client:ODMappedClientManager) => api.ODPromiseVoid>
|
||||
"afterTextCommandsLoaded": api.ODEvent<(text:ODMappedTextCommandManager, client:ODMappedClientManager) => api.ODPromiseVoid>
|
||||
|
||||
//states
|
||||
"onStateLoad": api.ODEvent<(posts:ODMappedStateManager) => api.ODPromiseVoid>
|
||||
"afterStatesLoaded": api.ODEvent<(posts:ODMappedStateManager) => api.ODPromiseVoid>
|
||||
"onStateInit": api.ODEvent<(posts:ODMappedStateManager) => api.ODPromiseVoid>
|
||||
"afterStatesInitiated": api.ODEvent<(posts:ODMappedStateManager) => api.ODPromiseVoid>
|
||||
|
||||
//plugin loading before managers
|
||||
"onPluginBeforeManagerLoad": api.ODEvent<() => api.ODPromiseVoid>,
|
||||
"afterPluginBeforeManagerLoaded": api.ODEvent<() => api.ODPromiseVoid>,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
///////////////////////////////////////
|
||||
//OPEN TICKET STATE MAPPINGS
|
||||
///////////////////////////////////////
|
||||
import * as api from "@open-discord-bots/framework/api"
|
||||
import * as discord from "discord.js"
|
||||
|
||||
/**## ODStateManagerIdMappings `interface`
|
||||
* A list of all available IDs in the default `ODStateManager` class in `opendiscord`.
|
||||
* It's used to generate typescript declarations for this class.
|
||||
*/
|
||||
export interface ODStateManagerIdMappings extends api.ODStateManagerIdConstraint {
|
||||
//"opendiscord:example-state":api.ODState<any>,
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
////// MAPPED MANAGERS //////
|
||||
/////////////////////////////
|
||||
|
||||
/**## ODMappedStateManager `class
|
||||
* A special class with types for the Open Ticket `ODStateManager` class.
|
||||
*/
|
||||
export class ODMappedStateManager extends api.ODStateManager<ODStateManagerIdMappings> {}
|
||||
@@ -78,7 +78,7 @@ export const loadDatabaseCleanersCode = async () => {
|
||||
if (!validPanels.includes(panel.key)){
|
||||
try{
|
||||
const splittedId = panel.key.split("_")
|
||||
const message = await opendiscord.client.fetchGuildChannelMessage(mainServer,splittedId[0],splittedId[1])
|
||||
const message = await opendiscord.client.fetchChannelMessage(splittedId[0],splittedId[1])
|
||||
if (message) validPanels.push(panel.key)
|
||||
}catch{}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ export const loadPanelAutoUpdateCode = async () => {
|
||||
const splittedId = panelId.key.split("_")
|
||||
const channel = await opendiscord.client.fetchGuildTextChannel(mainServer,splittedId[0])
|
||||
if (!channel) return
|
||||
const message = await opendiscord.client.fetchGuildChannelMessage(mainServer,channel,splittedId[1])
|
||||
const message = await opendiscord.client.fetchChannelMessage(channel,splittedId[1])
|
||||
if (!message || !message.editable) return
|
||||
|
||||
message.edit((await opendiscord.builders.messages.getSafe("opendiscord:panel").build("auto-update",{guild:mainServer,channel,user:opendiscord.client.client.user,panel})).message)
|
||||
|
||||
@@ -96,6 +96,12 @@ export const loadAllEvents = () => {
|
||||
"onTextCommandLoad",
|
||||
"afterTextCommandsLoaded",
|
||||
|
||||
//states
|
||||
"onStateLoad",
|
||||
"afterStatesLoaded",
|
||||
"onStateInit",
|
||||
"afterStatesInitiated",
|
||||
|
||||
//plugin loading before managers
|
||||
"onPluginBeforeManagerLoad",
|
||||
"afterPluginBeforeManagerLoaded",
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import {opendiscord, api, utilities} from "../../index.js"
|
||||
|
||||
export const loadAllStates = async () => {
|
||||
|
||||
}
|
||||
+16
-1
@@ -514,6 +514,21 @@ const main = async () => {
|
||||
opendiscord.log("discord.js client ready!","info")
|
||||
}
|
||||
|
||||
//load states
|
||||
opendiscord.log("Loading states...","system")
|
||||
if (opendiscord.sharedFuses.getFuse("stateLoading")){
|
||||
await (await import("./data/framework/stateLoader.js")).loadAllStates()
|
||||
}
|
||||
await opendiscord.events.get("onStateLoad").emit([opendiscord.states])
|
||||
await opendiscord.events.get("afterStatesLoaded").emit([opendiscord.states])
|
||||
|
||||
//init states
|
||||
await opendiscord.events.get("onStateInit").emit([opendiscord.states])
|
||||
if (opendiscord.sharedFuses.getFuse("stateInitiating")){
|
||||
await opendiscord.states.init()
|
||||
await opendiscord.events.get("afterStatesInitiated").emit([opendiscord.states])
|
||||
}
|
||||
|
||||
//plugin loading before managers
|
||||
await opendiscord.events.get("onPluginBeforeManagerLoad").emit([])
|
||||
await opendiscord.events.get("afterPluginBeforeManagerLoaded").emit([])
|
||||
@@ -813,7 +828,7 @@ const main = async () => {
|
||||
//init posts
|
||||
await opendiscord.events.get("onPostInit").emit([opendiscord.posts])
|
||||
if (opendiscord.sharedFuses.getFuse("postsInitiating")){
|
||||
if (opendiscord.client.mainServer) opendiscord.posts.init(opendiscord.client.mainServer)
|
||||
if (opendiscord.client.mainServer) await opendiscord.posts.init(opendiscord.client.mainServer)
|
||||
await opendiscord.events.get("afterPostsInitiated").emit([opendiscord.posts])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user