mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-20 05:51:39 +01:00
add command enabling/disabling, only by admins
This commit is contained in:
@@ -6,18 +6,21 @@ export class Command {
|
||||
public readonly name: string;
|
||||
public readonly aliases: string[];
|
||||
public readonly requiredIntents: string[];
|
||||
public readonly disableable: boolean;
|
||||
public readonly execute: (message: EventSubChannelChatMessageEvent, sender: User) => Promise<void>;
|
||||
constructor(name: string, aliases: string[], requiredIntents: string[], execution: (message: EventSubChannelChatMessageEvent, sender: User) => Promise<void>) {
|
||||
this.name = name;
|
||||
constructor(name: string, aliases: string[], requiredIntents: string[], execution: (message: EventSubChannelChatMessageEvent, sender: User) => Promise<void>, disableable?: boolean) {
|
||||
this.name = name.toLowerCase();
|
||||
this.aliases = aliases;
|
||||
this.requiredIntents = requiredIntents;
|
||||
this.execute = execution;
|
||||
this.disableable = disableable ?? true;
|
||||
};
|
||||
};
|
||||
|
||||
import { readdir } from 'node:fs/promises';
|
||||
const commands = new Map<string, Command>;
|
||||
const commandintents: string[] = [];
|
||||
const basecommands = new Map<string, Command>;
|
||||
|
||||
const files = await readdir(import.meta.dir);
|
||||
for (const file of files) {
|
||||
@@ -25,6 +28,7 @@ for (const file of files) {
|
||||
if (file === import.meta.file) continue;
|
||||
const command: Command = await import(import.meta.dir + '/' + file.slice(0, -3)).then(a => a.default);
|
||||
commandintents.push(...command.requiredIntents);
|
||||
basecommands.set(command.name, command);
|
||||
for (const alias of command.aliases) {
|
||||
commands.set(alias, command); // Since it's not a primitive type the map is filled with references to the command, not the actual object
|
||||
};
|
||||
@@ -36,7 +40,7 @@ for (const [name, item] of Array.from(items)) {
|
||||
};
|
||||
|
||||
export default commands;
|
||||
export { commandintents };
|
||||
export { commandintents, basecommands };
|
||||
|
||||
import { singleUserMode, chatterApi, chatterId, streamerId } from "..";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user