venbot-tg/src/commands/help.ts
2024-09-23 21:14:12 -04:00

34 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Context } from "telegraf";
import { CommandTypes } from "../utils/types";
import { commands } from "../client";
async function handler(ctx: Context, args: string[]) {
if (args.length === 1) {
const cmd = commands.find((c) => c.name === args[0]);
if (!cmd) return await ctx.reply("Command not found");
return await ctx.replyWithMarkdown(
`*${cmd.name}${cmd.aliases.length ? ` (${cmd.aliases.join(", ")})` : ""}*\n${cmd.description}\n${cmd.modOnly ? "_🛡 Mod only_" : ""}${cmd.ownerOnly ? "_👑 Owner only_" : ""}`
);
} else {
const cmds = commands;
cmds.sort((a, b) => a.name.localeCompare(b.name)); // Sort commands alphabetically by name
return await ctx.replyWithMarkdown(
cmds
.map(
(c) =>
`*${c.name}*${c.aliases.length ? `_ (${c.aliases.join(", ")})_` : ""}${c.ownerOnly ? " 👑" : ""}${c.modOnly ? " 🛡️" : ""} - ${c.description}`
)
.join("\n")
);
}
}
export const help = {
name: "help",
aliases: ["h", "?"],
description: "Get bot help",
type: CommandTypes.Info,
modOnly: false,
ownerOnly: false,
handler
};