mirror of
https://gitlab.com/qwerinope/qweribot.git
synced 2026-02-04 15:06:58 +01:00
add command enabling/disabling, only by admins
This commit is contained in:
15
bot/commands/enablecommand.ts
Normal file
15
bot/commands/enablecommand.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { redis } from "bun";
|
||||
import commands, { Command, sendMessage } from ".";
|
||||
import { isAdmin } from "../lib/admins";
|
||||
import parseCommandArgs from "../lib/parseCommandArgs";
|
||||
|
||||
export default new Command('enablecommand', ['enablecommand'], [], async msg => {
|
||||
if (!await isAdmin(msg.chatterId)) return;
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) { await sendMessage('Please specify a command to enable', msg.messageId); return; };
|
||||
const selection = commands.get(args[0].toLowerCase());
|
||||
if (!selection) { await sendMessage(`There is no ${args[0]} command`, msg.messageId); return; };
|
||||
const result = await redis.srem('disabledcommands', selection.name);
|
||||
if (result === 0) { await sendMessage(`The ${selection.name} command isn't disabled`, msg.messageId); return; };
|
||||
await sendMessage(`Successfully enabled the ${selection.name} command`, msg.messageId);
|
||||
}, false);
|
||||
Reference in New Issue
Block a user