Add debug mode, prefix config file

This commit is contained in:
Hri7566 2023-12-06 19:31:08 -05:00
parent 787fda193a
commit d3499d2bbd
5 changed files with 31 additions and 12 deletions

5
config/prefixes.yml Normal file
View File

@ -0,0 +1,5 @@
prefixes:
- id: cosmic
spaced: true
- id: "*"
spaced: false

View File

@ -1,3 +1,4 @@
debug: false
enableConsole: true enableConsole: true
enableMPP: true enableMPP: true
enableDiscord: true enableDiscord: true

View File

@ -8,6 +8,20 @@ import { createInventory, readInventory } from "../data/inventory";
import { hasPermission } from "../permissions"; import { hasPermission } from "../permissions";
import { Logger } from "../util/Logger"; import { Logger } from "../util/Logger";
import { balanceConfig } from "../economy/Balance"; import { balanceConfig } from "../economy/Balance";
import { loadConfig } from "../util/config";
const prefixConfig = loadConfig("config/prefixes.yml", {
prefixes: [
{
id: "cosmic",
spaced: true
},
{
id: "*",
spaced: false
}
]
});
export interface CommandMessage<T = unknown> { export interface CommandMessage<T = unknown> {
m: "command"; m: "command";
@ -32,16 +46,7 @@ export type BaseCommandMessage<T = unknown> = Omit<
export class CommandHandler { export class CommandHandler {
public static commandGroups = new Array<CommandGroup>(); public static commandGroups = new Array<CommandGroup>();
public static prefixes = new Array<Prefix>( public static prefixes = new Array<Prefix>();
{
id: "cosmic",
spaced: true
},
{
id: "*",
spaced: false
}
);
public static logger = new Logger("Command Handler"); public static logger = new Logger("Command Handler");
@ -155,3 +160,8 @@ export class CommandHandler {
} }
} }
} }
// Add prefixes
for (const prefix of prefixConfig.prefixes) {
CommandHandler.prefixes.push(prefix);
}

View File

@ -11,6 +11,7 @@ import { DiscordAgent } from "./discord";
*/ */
const config = loadConfig("config/services.yml", { const config = loadConfig("config/services.yml", {
debug: false,
enableConsole: true, enableConsole: true,
enableMPP: false, enableMPP: false,
enableDiscord: false, enableDiscord: false,
@ -62,7 +63,8 @@ export class ServiceLoader {
color: mppConfig.desiredUser.color color: mppConfig.desiredUser.color
} }
: mppConfig.desiredUser, : mppConfig.desiredUser,
env.MPPNET_TOKEN env.MPPNET_TOKEN,
config.debug
); );
mppAgent.start(); mppAgent.start();

View File

@ -11,7 +11,8 @@ export class MPPAgent extends ServiceAgent<Client> {
uri: string, uri: string,
public desiredChannel: string, public desiredChannel: string,
public desiredUser: { name: string; color: string }, public desiredUser: { name: string; color: string },
token: string token: string,
public debug: boolean = false
) { ) {
const cl = new Client(uri, token); const cl = new Client(uri, token);
super("mpp", cl); super("mpp", cl);