2020-05-23 21:56:04 +02:00
|
|
|
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" },
|
2020-05-23 21:56:04 +02:00
|
|
|
type: "copy",
|
|
|
|
});
|
2020-05-26 13:29:57 +02:00
|
|
|
const text = command?.content.text || command?.content.caption;
|
|
|
|
if (!text) return match;
|
|
|
|
return text + " ";
|
2020-05-23 21:56:04 +02:00
|
|
|
});
|