Merge branch 'DJj123dj:dev' into dev
This commit is contained in:
@@ -26,24 +26,32 @@ You're also able to customise every little aspect of the bot! From embeds to tra
|
||||
> The translation count may not be accurate!
|
||||
|
||||
### 📌 Features
|
||||
- **💩 no bloat/credits** - Your Open Ticket bot doesn't contain any form of bloat or credits!
|
||||
- **💩 no bloat** - Your Open Ticket bot doesn't contain any form of bloat or credits!
|
||||
- **🔒 tested & secure** - Open Ticket has been tested by thousands of servers and is very secure!
|
||||
- **📈 scalable** - Open Ticket is made to handle huge servers! Even if your server contains more than 100k members!
|
||||
- **📄 html transcripts** - Make use of the most customisable, beautiful and easy-to-use HTML Transcripts!
|
||||
- **📈 scalable** - Open Ticket is made to handle huge servers! (Already tested in **servers with 100k members**)
|
||||
- **📄 HTML transcripts** - Make use of the most customisable, beautiful and easy-to-use HTML Transcripts!
|
||||
- **✅ ticket actions** - Close, Reopen, Delete, Rename & Move all your tickets!
|
||||
- **🇬🇧 translation** - Open Ticket has been translated in more than **16 languages** by our community!
|
||||
- **🇬🇧 translation** - Open Ticket has been translated in more than **20 languages** by our community!
|
||||
- **🎨 customisation** - Open Ticket has been created around customisation, everything can be customised!
|
||||
- **🖥️ interactions** - The bot has full support for Buttons, Dropdowns, Slash Commands and Modals!
|
||||
- **∞ unlimited everywhere** - Create an infinite amount of tickets & panels!
|
||||
- **📝 advanced plugins** - Create the most advanced plugins that you want or use premade ones by our community!
|
||||
- **∞ unlimited** - Create an infinite amount of tickets & panels!
|
||||
- **📝 advanced plugins** - Create advanced plugins or use pre-made ones by our community!
|
||||
- **👥 user management** - Add & Remove users from all tickets!
|
||||
- **📊 detailed stats** - Open Ticket has ticket, user & global staticstics available for everyone!
|
||||
- **🚫 blacklist** - Blacklist users to prevent them from creating a ticket!
|
||||
- **❓ questions** - Let users answer questions in a modal before the ticket is created!
|
||||
- **📦 commands** - Open Ticket supports both slash & text commands!
|
||||
- **📥 extra types** - The bot also supports Reaction Roles & Url Buttons, because why not ¯\\_(ツ)_/¯
|
||||
- **🎛️ dependencies** - We try to use as little external dependencies as needed!
|
||||
- **📢 commands** - The bot contains more than 25 commands! And it's expandable with plugins!
|
||||
- **📥 extra buttons** - The bot also supports Reaction Roles & Url Buttons, because why not ¯\\_(ツ)_/¯
|
||||
- **✨ commands** - The bot contains more than 25 commands!
|
||||
|
||||
#### And more using plugins!
|
||||
- **💬 reviews** - Create & customise your own review system!
|
||||
- **📢 feedback** - Collect feedback & create forms for people to answer!
|
||||
- **🔄 rotating status** - Create a rotating bot status & use dynamic variables from the bot!
|
||||
- **💾 sqlite database** - Use an `sqlite` database for increased performances!
|
||||
- **🎉 custom embeds** - Create your own embeds and use them in your server!
|
||||
- **🎨 customisation** - Yep, you heard it right! Even more customisation!
|
||||
- **😁 And so much more...**
|
||||
|
||||
> ### 📦 Resources
|
||||
> Resources might not be accurate yet! *(because v4 is still in beta)*<br>
|
||||
@@ -52,13 +60,19 @@ You're also able to customise every little aspect of the bot! From embeds to tra
|
||||
> <a href="https://github.com/DJj123dj/open-discord-plugins"><img src="https://apis.dj-dj.be/cdn/openticket/open-ticket-plugins.png" alt="Open Ticket Plugins" width="180px"></a>
|
||||
|
||||
## 📸 Preview
|
||||
<img alt="Ticket Message" width="550px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/ticket.png">
|
||||
<img alt="Ticket Stats Message" width="550px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/stats.png">
|
||||
<img alt="Example Panel 1" width="550px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/panel-1.png">
|
||||
<img alt="Example Panel 2" width="550px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/panel-2.png">
|
||||
<img alt="Ticket Message" width="350px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/ticket.png">
|
||||
<img alt="Ticket Stats Message" width="350px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/stats.png">
|
||||
<img alt="Example Panel 1" width="350px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/panel-1.png">
|
||||
<img alt="Example Panel 2" width="350px" src="https://apis.dj-dj.be/cdn/openticket/preview-v4/panel-2.png">
|
||||
|
||||
## 🧩 Plugins
|
||||
**Download all plugins in our [Official Plugin Repository](https://github.com/DJj123dj/open-discord-plugins)!**
|
||||
**Download all plugins in our [Official Plugin Repository](https://github.com/DJj123dj/open-discord-plugins)!**<br>
|
||||
> #### ⭐ Featured Plugins (Top 5 Most Used)
|
||||
> **[`ot-sqlite-database`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-sqlite-database/),
|
||||
> [`ot-migrate-v3`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-migrate-v3/),
|
||||
> [`ot-reviews`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-reviews/),
|
||||
> [`ot-feedback`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-feedback/),
|
||||
> [`ot-customise-buttons`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-customise-buttons/)**
|
||||
|
||||
### 📦 Official *(made by DJdj Development)*
|
||||
|Name |Category |Description |
|
||||
@@ -68,15 +82,18 @@ You're also able to customise every little aspect of the bot! From embeds to tra
|
||||
|[`ot-jump-to-top`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-jump-to-top/) |📢 Command |Add a simple command to jump to the top of the ticket. |
|
||||
|[`ot-kill-switch`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-kill-switch/) |📢 Command |Temporarily disable the ticket system using a kill switch. |
|
||||
|[`ot-hosting-status`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-hosting-status/) |📢 Command |A simple command to send hosting status updates to a channel. |
|
||||
|[`ot-shutdown`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-shutdown/) |📢 Command |A simple command to turn off the bot from a slash command (server & bot owner only). |
|
||||
|[`ot-sqlite-database`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-sqlite-database/) |⚙️ Utility |With this plugin, the database will be an SQLite file. It's a must-have for large servers! |
|
||||
|[`ot-no-slash-clear`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-no-slash-clear/) |⚙️ Utility |Disable the automatic removal of slash commands that aren't used by Open Ticket. |
|
||||
|[`ot-migrate-v3`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-migrate-v3/) |⚙️ Utility |Use this plugin to migrate all tickets from Open Ticket v3 to v4. |
|
||||
|[`ot-ticket-message-extras`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-ticket-message-extras/) |🎨 Customisation |A plugin which adds a few little features to the ticket message. |
|
||||
|[`ot-rename-keep-prefix`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-rename-keep-prefix/) |🎨 Customisation |Simple plugin to keep the channel prefix when using the /rename command. |
|
||||
|[`ot-customise-buttons`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-customise-buttons/) |🎨 Customisation |Customise almost all built-in buttons. This includes the claim, reopen, close & delete buttons. |
|
||||
|[`ot-alt-detector`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-alt-detector/) |💼 Management |Use the discord-alt-detector npm package by DJdj Development in your ticket bot. |
|
||||
|[`ot-ephemeral-messages`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-ephemeral-messages/) |🎨 Customisation |Customise for every messages if it needs to be ephemeral or not. |
|
||||
|[`ot-alt-detector`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-alt-detector/) |💼 Management |Use the discord-alt-detector npm package by DJdj Development in your ticket bot. |
|
||||
|[`ot-embeds`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-embeds/) |💼 Management |Create custom premade embeds in the config or use the command to create one from scratch. |
|
||||
|[`ot-move-actions`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-move-actions/) |💼 Management |Automatically unclaim/unpin a ticket when it's moved using `/move`. |
|
||||
|[`ot-reviews`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-reviews/) |💼 Management |Review system for Open Ticket! It is very customisable and has lots of features. |
|
||||
|[`ot-better-status`](https://github.com/DJj123dj/open-discord-plugins/tree/main/open-ticket/ot-better-status/) |🤖 Client |An advanced status plugin to rotate between states. It also allows for the use of variables. |
|
||||
|
||||
### ✅ Verified *(made by community)*
|
||||
@@ -182,6 +199,6 @@ Please help us grow by giving a star! It would help us a lot!
|
||||
<img src="https://apis.dj-dj.be/cdn/openticket/logo.png" alt="Open Ticket Logo" width="170px">
|
||||
|
||||
**README.md**<br>
|
||||
[changelog](https://otgithub.dj-dj.be/releases) - [documentation](https://otdocs.dj-dj.be) - [tutorial](https://www.youtube.com/watch?v=2jK9kAf6ASU) - [website](https://openticket.dj-dj.be) - [discord](https://discord.dj-dj.be)<br>
|
||||
[changelog](https://otgithub.dj-dj.be/releases) - [documentation](https://otdocs.dj-dj.be) - [tutorial](https://www.youtube.com/watch?v=2jK9kAf6ASU) - [website](https://openticket.dj-dj.be) - [discord](https://discord.dj-dj.be) - [license](./LICENSE.md)<br>
|
||||
|
||||
© 2025 - [DJdj Development](https://www.dj-dj.be) - [Terms](https://www.dj-dj.be/terms#terms) - [Privacy Policy](https://www.dj-dj.be/terms#privacy)
|
||||
@@ -8,7 +8,7 @@
|
||||
"priority":0,
|
||||
"events":[],
|
||||
|
||||
"npmDependencies":["discord.js"],
|
||||
"npmDependencies":[],
|
||||
"requiredPlugins":[],
|
||||
"incompatiblePlugins":[],
|
||||
|
||||
|
||||
@@ -143,6 +143,14 @@ export class ODLanguageManager extends ODManager<ODLanguage> {
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODLanguage `class`
|
||||
* This is an open ticket language file.
|
||||
*
|
||||
* It contains metadata and all translation strings available in this language.
|
||||
* Register this class to an `ODLanguageManager` to use it!
|
||||
*
|
||||
* JSON languages should be created using the `ODJsonLanguage` class instead!
|
||||
*/
|
||||
export class ODLanguage extends ODManagerData {
|
||||
/**The name of the file with extension. */
|
||||
file: string = ""
|
||||
@@ -164,6 +172,14 @@ export class ODLanguage extends ODManagerData {
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODJsonLanguage `class`
|
||||
* This is an open ticket JSON language file.
|
||||
*
|
||||
* It contains metadata and all translation strings from a certain JSON file (in `./languages/`).
|
||||
* Register this class to an `ODLanguageManager` to use it!
|
||||
*
|
||||
* Use the `ODLanguage` class to use translations from non-JSON files!
|
||||
*/
|
||||
export class ODJsonLanguage extends ODLanguage {
|
||||
constructor(id:ODValidId, file:string, customPath?:string){
|
||||
super(id,{})
|
||||
|
||||
@@ -5,28 +5,65 @@ import { ODId, ODValidId, ODManager, ODSystemError, ODManagerData } from "./base
|
||||
import * as discord from "discord.js"
|
||||
import { ODDebugger } from "./console"
|
||||
|
||||
/**## ODPermissionType `type`
|
||||
* All available permission types/levels. Can be used in the `ODPermission` class.
|
||||
*/
|
||||
export type ODPermissionType = "member"|"support"|"moderator"|"admin"|"owner"|"developer"
|
||||
|
||||
/**## ODPermissionScope `type`
|
||||
* The scope in which a certain permission is active.
|
||||
*/
|
||||
export type ODPermissionScope = "global-user"|"channel-user"|"global-role"|"channel-role"
|
||||
|
||||
/**## ODPermissionResult `interface`
|
||||
* The result returned by `ODPermissionManager.getPermissions()`.
|
||||
*/
|
||||
export interface ODPermissionResult {
|
||||
/**The permission type. */
|
||||
type:ODPermissionType
|
||||
/**The permission scope. */
|
||||
scope:ODPermissionScope|"default"
|
||||
/**The highest level available for this scope. */
|
||||
level:ODPermissionLevel,
|
||||
/**The permission which returned this level. */
|
||||
source:ODPermission|null
|
||||
}
|
||||
|
||||
/**## ODPermissionLevel `enum`
|
||||
* All available permission types/levels. But as `enum` instead of `type`. Used to calculate the level.
|
||||
*/
|
||||
export enum ODPermissionLevel {
|
||||
/**A normal member. (Default for everyone) */
|
||||
member,
|
||||
/**Support team. Higher than a normal member. (Used for ticket-admins) */
|
||||
support,
|
||||
/**Moderator. Higher than the support team. (Unused) */
|
||||
moderator,
|
||||
/**Admin. Higher than a moderator. (Used for global-admins) */
|
||||
admin,
|
||||
/**Server owner. (Able to use all commands including `/stats reset`) */
|
||||
owner,
|
||||
/**Bot owner or all users from dev team. (Able to use all commands including `/stats reset`) */
|
||||
developer
|
||||
}
|
||||
|
||||
/**## ODPermission `class`
|
||||
* This is an open ticket permission.
|
||||
*
|
||||
* It defines a single permission level for a specific scope (global/channel & user/role)
|
||||
* These permissions only apply to commands & interactions.
|
||||
* They are not related to channel permissions in the ticket system.
|
||||
*
|
||||
* Register this class to an `ODPermissionManager` to use it!
|
||||
*/
|
||||
export class ODPermission extends ODManagerData {
|
||||
/**The scope of this permission. */
|
||||
readonly scope: ODPermissionScope
|
||||
/**The type/level of this permission. */
|
||||
readonly permission: ODPermissionType
|
||||
/**The user/role of this permission. */
|
||||
readonly value: discord.Role|discord.User
|
||||
/**The channel that this permission applies to. (`null` when global) */
|
||||
readonly channel: discord.Channel|null
|
||||
|
||||
constructor(id:ODValidId, scope:"global-user", permission:ODPermissionType, value:discord.User)
|
||||
@@ -42,18 +79,39 @@ export class ODPermission extends ODManagerData {
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODPermissionSettings `interface`
|
||||
* Optional settings for the `getPermissions()` method in the `ODPermissionManager`.
|
||||
*/
|
||||
export interface ODPermissionSettings {
|
||||
/**Include permissions from the global user scope. */
|
||||
allowGlobalUserScope?:boolean,
|
||||
/**Include permissions from the global role scope. */
|
||||
allowGlobalRoleScope?:boolean,
|
||||
/**Include permissions from the channel user scope. */
|
||||
allowChannelUserScope?:boolean,
|
||||
/**Include permissions from the channel role scope. */
|
||||
allowChannelRoleScope?:boolean,
|
||||
/**Only include permissions of which the id matches this regex. */
|
||||
idRegex?:RegExp
|
||||
}
|
||||
|
||||
/**## ODPermissionCalculationCallback `type`
|
||||
* The callback of the permission calculation. (Used in `ODPermissionManager`)
|
||||
*/
|
||||
export type ODPermissionCalculationCallback = (user:discord.User, channel?:discord.Channel|null, guild?:discord.Guild|null, settings?:ODPermissionSettings|null) => Promise<ODPermissionResult>
|
||||
|
||||
/**## ODPermissionManager `class`
|
||||
* This is an open ticket permission manager.
|
||||
*
|
||||
* It manages all permissions in the bot!
|
||||
* Use the `getPermissions()` and `hasPermissions()` methods to get user perms.
|
||||
*
|
||||
* Add new permissions using the `ODPermission` class in your plugin!
|
||||
*/
|
||||
export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
/**The function for calculating permissions in this manager. */
|
||||
#calculation: ODPermissionCalculationCallback|null
|
||||
/**The result which is returned when no other permissions match. (`member` by default) */
|
||||
defaultResult: ODPermissionResult = {
|
||||
level:ODPermissionLevel["member"],
|
||||
scope:"default",
|
||||
@@ -66,12 +124,15 @@ export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
this.#calculation = useDefaultCalculation ? this.#defaultCalculation : null
|
||||
}
|
||||
|
||||
/**Edit the permission calculation function in this manager. */
|
||||
setCalculation(calculation:ODPermissionCalculationCallback){
|
||||
this.#calculation = calculation
|
||||
}
|
||||
/**Edit the result which is returned when no other permissions match. (`member` by default) */
|
||||
setDefaultResult(result:ODPermissionResult){
|
||||
this.defaultResult = result
|
||||
}
|
||||
/**Get an `ODPermissionResult` based on a few context factors. Use `hasPermissions()` to simplify the result. */
|
||||
getPermissions(user:discord.User, channel?:discord.Channel|null, guild?:discord.Guild|null, settings?:ODPermissionSettings|null): Promise<ODPermissionResult> {
|
||||
try{
|
||||
if (!this.#calculation) throw new ODSystemError("ODPermissionManager:getPermissions() => missing perms calculation")
|
||||
@@ -81,6 +142,7 @@ export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
throw new ODSystemError("ODPermissionManager:getPermissions() => failed perms calculation")
|
||||
}
|
||||
}
|
||||
/**Simplifies the `ODPermissionResult` returned from `getPermissions()` and returns a boolean to check if the user matches the required permissions. */
|
||||
hasPermissions(minimum:ODPermissionType, data:ODPermissionResult){
|
||||
if (minimum == "member") return true
|
||||
else if (minimum == "support") return (data.level >= ODPermissionLevel["support"])
|
||||
@@ -90,6 +152,7 @@ export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
else if (minimum == "developer") return (data.level >= ODPermissionLevel["developer"])
|
||||
else throw new ODSystemError("Invalid minimum permission type at ODPermissionManager.hasPermissions()")
|
||||
}
|
||||
/**Check for permissions. (default calculation) */
|
||||
async #defaultCalculation(user:discord.User,channel?:discord.Channel|null,guild?:discord.Guild|null, settings?:ODPermissionSettings|null): Promise<ODPermissionResult> {
|
||||
const globalCalc = await this.#defaultGlobalCalculation(user,channel,guild,settings)
|
||||
const channelCalc = await this.#defaultChannelCalculation(user,channel,guild,settings)
|
||||
@@ -97,7 +160,7 @@ export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
if (globalCalc.level > channelCalc.level) return globalCalc
|
||||
else return channelCalc
|
||||
}
|
||||
/**Check for global permissions. Then this result can be compared with the channel one. */
|
||||
/**Check for global permissions. Result will be compared with the channel perms in `#defaultCalculation()`. */
|
||||
async #defaultGlobalCalculation(user:discord.User,channel?:discord.Channel|null,guild?:discord.Guild|null, settings?:ODPermissionSettings|null): Promise<ODPermissionResult> {
|
||||
const idRegex = (settings && typeof settings.idRegex != "undefined") ? settings.idRegex : null
|
||||
const allowGlobalUserScope = (settings && typeof settings.allowGlobalUserScope != "undefined") ? settings.allowGlobalUserScope : true
|
||||
@@ -160,7 +223,7 @@ export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
//spread result to prevent accidental referencing
|
||||
return {...this.defaultResult}
|
||||
}
|
||||
/**Check for channel permissions. Then this result can be compared with the global one. */
|
||||
/**Check for channel permissions. Result will be compared with the global perms in `#defaultCalculation()`. */
|
||||
async #defaultChannelCalculation(user:discord.User,channel?:discord.Channel|null,guild?:discord.Guild|null, settings?:ODPermissionSettings|null): Promise<ODPermissionResult> {
|
||||
const idRegex = (settings && typeof settings.idRegex != "undefined") ? settings.idRegex : null
|
||||
const allowChannelUserScope = (settings && typeof settings.allowChannelUserScope != "undefined") ? settings.allowChannelUserScope : true
|
||||
@@ -220,7 +283,7 @@ export class ODPermissionManager extends ODManager<ODPermission> {
|
||||
}
|
||||
}
|
||||
|
||||
//spread result to prevent accidental referencing
|
||||
//spread result to prevent accidental modification because of referencing
|
||||
return {...this.defaultResult}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,29 @@ import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId, ODVersion } f
|
||||
import nodepath from "path"
|
||||
import { ODConsolePluginMessage, ODConsoleWarningMessage, ODDebugger } from "./console"
|
||||
|
||||
/**## ODUnknownCrashedPlugin `interface`
|
||||
* Basic details for a plugin that crashed while loading the `plugin.json` file.
|
||||
*/
|
||||
export interface ODUnknownCrashedPlugin {
|
||||
/**The name of the plugin. (path when plugin crashed before `name` was loaded) */
|
||||
name:string,
|
||||
/**The description of the plugin. (when found before crashing) */
|
||||
description:string
|
||||
}
|
||||
|
||||
/**## ODPluginManager `class`
|
||||
* This is an open ticket plugin manager.
|
||||
*
|
||||
* It manages all active plugins in the bot!
|
||||
* It also contains all "plugin classes" which are managers registered by plugins.
|
||||
* These are accessible via the `openticket.plugins.classes` global.
|
||||
*
|
||||
* Use `isPluginLoaded()` to check if a plugin has been loaded.
|
||||
*/
|
||||
export class ODPluginManager extends ODManager<ODPlugin> {
|
||||
/**A manager for all custom managers registered by plugins. */
|
||||
classes: ODPluginClassManager
|
||||
/**A list of basic details from all plugins that crashed while loading the `plugin.json` file. */
|
||||
unknownCrashedPlugins: ODUnknownCrashedPlugin[] = []
|
||||
|
||||
constructor(debug:ODDebugger){
|
||||
@@ -19,7 +35,7 @@ export class ODPluginManager extends ODManager<ODPlugin> {
|
||||
this.classes = new ODPluginClassManager(debug)
|
||||
}
|
||||
|
||||
/**Check if a plugin has loaded successfully.*/
|
||||
/**Check if a plugin has been loaded successfully and is available for usage.*/
|
||||
isPluginLoaded(id:ODValidId): boolean {
|
||||
const newId = new ODId(id)
|
||||
const plugin = this.get(newId)
|
||||
@@ -27,43 +43,84 @@ export class ODPluginManager extends ODManager<ODPlugin> {
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODPluginData `interface`
|
||||
* Parsed data from the `plugin.json` file in a plugin.
|
||||
*/
|
||||
export interface ODPluginData {
|
||||
/**The name of this plugin (shown on startup) */
|
||||
name:string,
|
||||
/**The id of this plugin. (Must be identical to directory name) */
|
||||
id:string,
|
||||
/**The version of this plugin. */
|
||||
version:string,
|
||||
/**The location of the start file of the plugin relative to the rootDir of the plugin */
|
||||
startFile:string,
|
||||
|
||||
/**Is this plugin enabled? */
|
||||
enabled:boolean,
|
||||
/**The priority of this plugin. Higher priority will load before lower priority. */
|
||||
priority:number,
|
||||
/**A list of events to register to the `openticket.events` global before loading any plugins. This way, plugins with a higher priority are able to use events from this plugin as well! */
|
||||
events:string[]
|
||||
|
||||
/**Npm dependencies which are required for this plugin to work. */
|
||||
npmDependencies:string[],
|
||||
/**Plugins which are required for this plugin to work. */
|
||||
requiredPlugins:string[],
|
||||
/**Plugins which are incompatible with this plugin. */
|
||||
incompatiblePlugins:string[],
|
||||
|
||||
/**Additional details about this plugin. */
|
||||
details:ODPluginDetails
|
||||
}
|
||||
|
||||
/**## ODPluginDetails `interface`
|
||||
* Additional details in the `plugin.json` file from a plugin.
|
||||
*/
|
||||
export interface ODPluginDetails {
|
||||
/**The author of the plugin. */
|
||||
author:string,
|
||||
/**A short description of this plugin. */
|
||||
shortDescription:string,
|
||||
/**A large description of this plugin. */
|
||||
longDescription:string,
|
||||
/**A URL to a cover image of this plugin. (currently unused) */
|
||||
imageUrl:string,
|
||||
/**A URL to the website/project page of this plugin. (currently unused) */
|
||||
projectUrl:string,
|
||||
/**A list of tags/categories that this plugin affects. */
|
||||
tags:string[]
|
||||
}
|
||||
|
||||
/**## ODPlugin `class`
|
||||
* This is an open ticket plugin.
|
||||
*
|
||||
* It represents a single plugin in the `./plugins/` directory.
|
||||
* All plugins are accessible via the `openticket.plugins` global.
|
||||
*
|
||||
* Don't re-execute plugins which are already enabled! It might break the bot or plugin.
|
||||
*/
|
||||
export class ODPlugin extends ODManagerData {
|
||||
/**The name of the directory of this plugin. (same as id) */
|
||||
dir: string
|
||||
/**All plugin data found in the `plugin.json` file. */
|
||||
data: ODPluginData
|
||||
/**The name of this plugin. */
|
||||
name: string
|
||||
/**The priority of this plugin. */
|
||||
priority: number
|
||||
/**The version of this plugin. */
|
||||
version: ODVersion
|
||||
/**The additional details of this plugin. */
|
||||
details: ODPluginDetails
|
||||
|
||||
/**Is this plugin enabled? */
|
||||
enabled: boolean
|
||||
/**Did this plugin execute successfully?. */
|
||||
executed: boolean
|
||||
/**Did this plugin crash? (A reason is available in the `crashReason`) */
|
||||
crashed: boolean
|
||||
/**The reason which caused this plugin to crash. */
|
||||
crashReason: null|"incompatible.plugin"|"missing.plugin"|"missing.dependency"|"executed" = null
|
||||
|
||||
constructor(dir:string, jsondata:ODPluginData){
|
||||
@@ -160,6 +217,16 @@ export class ODPlugin extends ODManagerData {
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODPluginClassManager `class`
|
||||
* This is an open ticket plugin class manager.
|
||||
*
|
||||
* It manages all managers registered by plugins!
|
||||
* Plugins are able to register their own managers, handlers, functions, classes, ... here.
|
||||
* By doing this, other plugins are also able to make use of it.
|
||||
* This can be useful for plugins that want to extend other plugins.
|
||||
*
|
||||
* Use `isPluginLoaded()` to check if a plugin has been loaded before trying to access the manager.
|
||||
*/
|
||||
export class ODPluginClassManager extends ODManager<ODManagerData> {
|
||||
constructor(debug:ODDebugger){
|
||||
super(debug,"plugin class")
|
||||
|
||||
@@ -8,12 +8,21 @@ import { ODButtonResponderInstance } from "./responder"
|
||||
import * as discord from "discord.js"
|
||||
import { ODWorkerManager } from "./worker"
|
||||
|
||||
export type ODVerifyBarCallback = (responder:ODButtonResponderInstance,customData?:string) => void|Promise<void>
|
||||
|
||||
/**## ODVerifyBar `class`
|
||||
* This is an open ticket verifybar.
|
||||
*
|
||||
* It is contains 2 sets of workers and a lot of utilities for the (✅ ❌) verifybars in the bot.
|
||||
*
|
||||
* It doesn't contain the code which activates or spawns the verifybars!
|
||||
*/
|
||||
export class ODVerifyBar extends ODManagerData {
|
||||
/**All workers that will run when the verifybar is accepted. */
|
||||
success: ODWorkerManager<ODButtonResponderInstance,"verifybar",{data:string|null,verifybarMessage:discord.Message<boolean>|null}>
|
||||
/**All workers that will run when the verifybar is stopped. */
|
||||
failure: ODWorkerManager<ODButtonResponderInstance,"verifybar",{data:string|null,verifybarMessage:discord.Message<boolean>|null}>
|
||||
/**The message that will be built wen activating this verifybar. */
|
||||
message: ODMessage<"verifybar",{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:ODVerifyBar,originalMessage:discord.Message<boolean>}>
|
||||
/**When disabled, it will skip the verifybar and instantly fire the `success` workers. */
|
||||
enabled: boolean
|
||||
|
||||
constructor(id:ODValidId, message:ODMessage<"verifybar",{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,originalMessage:discord.Message<boolean>}>, enabled?:boolean){
|
||||
@@ -24,6 +33,7 @@ export class ODVerifyBar extends ODManagerData {
|
||||
this.enabled = enabled ?? true
|
||||
}
|
||||
|
||||
/**Build the message and reply to a button with this verifybar. */
|
||||
async activate(responder:ODButtonResponderInstance){
|
||||
if (this.enabled){
|
||||
//show verifybar
|
||||
@@ -36,6 +46,14 @@ export class ODVerifyBar extends ODManagerData {
|
||||
}
|
||||
}
|
||||
|
||||
/**## ODVerifyBarManager `class`
|
||||
* This is an open ticket verifybar manager.
|
||||
*
|
||||
* It contains all (✅ ❌) verifybars in the bot.
|
||||
* The `ODVerifyBar` classes contain `ODWorkerManager`'s that will be fired when the continue/stop buttons are pressed.
|
||||
*
|
||||
* It doesn't contain the code which activates the verifybars! This should be implemented by your own.
|
||||
*/
|
||||
export class ODVerifyBarManager extends ODManager<ODVerifyBar> {
|
||||
constructor(debug:ODDebugger){
|
||||
super(debug,"verifybar")
|
||||
|
||||
Reference in New Issue
Block a user