mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 04:45:02 +00:00
automod.reply: allow embeds, add auto_delete option
This commit is contained in:
parent
1cff4fb801
commit
53a9c58dd4
4 changed files with 55 additions and 30 deletions
|
@ -204,6 +204,8 @@ export const tStrictMessageContent = t.type({
|
|||
embed: tNullable(tEmbed),
|
||||
});
|
||||
|
||||
export const tMessageContent = t.union([t.string, tStrictMessageContent]);
|
||||
|
||||
export function dropPropertiesByName(obj, propName) {
|
||||
if (obj.hasOwnProperty(propName)) delete obj[propName];
|
||||
for (const value of Object.values(obj)) {
|
||||
|
@ -1126,3 +1128,27 @@ export function memoize<T>(fn: (...args: any[]) => T, key?, time?): T {
|
|||
|
||||
return value;
|
||||
}
|
||||
|
||||
type RecursiveRenderFn = (str: string) => string | Promise<string>;
|
||||
|
||||
export async function renderRecursively(value, fn: RecursiveRenderFn) {
|
||||
if (Array.isArray(value)) {
|
||||
const result = [];
|
||||
for (const item of value) {
|
||||
result.push(await renderRecursively(item, fn));
|
||||
}
|
||||
return result;
|
||||
} else if (value === null) {
|
||||
return null;
|
||||
} else if (typeof value === "object") {
|
||||
const result = {};
|
||||
for (const [prop, _value] of Object.entries(value)) {
|
||||
result[prop] = await renderRecursively(_value, fn);
|
||||
}
|
||||
return result;
|
||||
} else if (typeof value === "string") {
|
||||
return fn(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue