2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-25 11:27:20 +00:00
the-guard-bot/utils/cmd/substom.ts

16 lines
487 B
TypeScript
Raw Permalink Normal View History

import replace = require("string-replace-async");
import { getCommand } from "../../stores/command";
export const substom = (reason: string): Promise<string> =>
replace(reason, /!\s?(\w+)\s*|.+/g, async (match, name) => {
if (!name) return match;
const command = await getCommand({
name: name.toLowerCase(),
2020-05-25 21:33:07 +02:00
role: { $ne: "master" },
type: "copy",
});
2020-05-26 13:29:57 +02:00
const text = command?.content.text || command?.content.caption;
if (!text) return match;
return text + " ";
});