mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-18 15:00:00 +00:00
39 lines
817 B
TypeScript
39 lines
817 B
TypeScript
import { MessageOptions } from "discord.js";
|
|
|
|
function embedHasContent(embed: any) {
|
|
for (const [key, value] of Object.entries(embed)) {
|
|
if (typeof value === "string" && value.trim() !== "") {
|
|
return true;
|
|
}
|
|
|
|
if (typeof value === "object" && value != null && embedHasContent(value)) {
|
|
return true;
|
|
}
|
|
|
|
if (value != null) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
export function messageHasContent(content: string | MessageOptions): boolean {
|
|
if (typeof content === "string") {
|
|
return content.trim() !== "";
|
|
}
|
|
|
|
if (content.content != null && content.content.trim() !== "") {
|
|
return true;
|
|
}
|
|
|
|
if (content.embeds) {
|
|
for (const embed of content.embeds) {
|
|
if (embed && embedHasContent(embed)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|