mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
starboard: note if the message contains audio or video attachments
This commit is contained in:
parent
867155019e
commit
5ec33848b4
1 changed files with 21 additions and 4 deletions
|
@ -5,6 +5,10 @@ import moment from "moment-timezone";
|
||||||
import { EmbedWith, EMPTY_CHAR, messageLink } from "../../../utils";
|
import { EmbedWith, EMPTY_CHAR, messageLink } from "../../../utils";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
|
const imageAttachmentExtensions = ["jpeg", "jpg", "png", "gif", "webp"];
|
||||||
|
const audioAttachmentExtensions = ["wav", "mp3", "m4a"];
|
||||||
|
const videoAttachmentExtensions = ["mp4", "mkv", "mov"];
|
||||||
|
|
||||||
export async function saveMessageToStarboard(
|
export async function saveMessageToStarboard(
|
||||||
pluginData: GuildPluginData<StarboardPluginType>,
|
pluginData: GuildPluginData<StarboardPluginType>,
|
||||||
msg: Message,
|
msg: Message,
|
||||||
|
@ -48,7 +52,9 @@ export async function saveMessageToStarboard(
|
||||||
embed.fields.push({ name: EMPTY_CHAR, value: titleText });
|
embed.fields.push({ name: EMPTY_CHAR, value: titleText });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.embeds[0].fields) embed.fields.push(...msg.embeds[0].fields);
|
if (msg.embeds[0].fields) {
|
||||||
|
embed.fields.push(...msg.embeds[0].fields);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +65,21 @@ export async function saveMessageToStarboard(
|
||||||
.extname(attachment.filename)
|
.extname(attachment.filename)
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
if (!["jpeg", "jpg", "png", "gif", "webp"].includes(ext)) continue;
|
|
||||||
|
|
||||||
embed.image = { url: attachment.url };
|
if (imageAttachmentExtensions.includes(ext)) {
|
||||||
break;
|
embed.image = { url: attachment.url };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioAttachmentExtensions.includes(ext)) {
|
||||||
|
embed.fields.push({ name: EMPTY_CHAR, value: `*Message contains an audio clip*` });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (videoAttachmentExtensions.includes(ext)) {
|
||||||
|
embed.fields.push({ name: EMPTY_CHAR, value: `*Message contains a video*` });
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue