-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActions.js
More file actions
48 lines (45 loc) · 2.04 KB
/
Actions.js
File metadata and controls
48 lines (45 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const Attachment = require('discord.js').Attachment;
const UrlValidator = require('./UrlValidator.js');
archiveMedia = (message) => {
// :wconsole.log(message);
const guild = message.guild;
if (!guild) return;
const embeds = message.embeds;
const attachments = message.attachments;
if (embeds) {
embeds.forEach((embed) => {
const ytMatch = UrlValidator.matchYTUrl(embed.url);
const igMatch = UrlValidator.matchIGUrl(embed.url);
const spMatch = UrlValidator.matchSpotifyUrl(embed.url);
const vlMatch = UrlValidator.matchVLiveUrl(embed.url);
if (ytMatch) {
const ytChannel = guild.channels.find(ch => ch.name === 'youtube-links');
if (ytChannel) ytChannel.send(ytMatch[0]);
} else if (igMatch) {
const igChannel = guild.channels.find(ch => ch.name === 'instagram-links');
if (igChannel) igChannel.send(igMatch[0]);
} else if (spMatch) {
const spChannel = guild.channels.find(ch => ch.name === 'spotify-links');
if (spChannel) spChannel.send(spMatch[0]);
} else if (vlMatch) {
const vliveChannel = guild.channels.find(ch => ch.name === 'vlive-links');
if (vliveChannel) vliveChannel.send(vlMatch[0]);
} else if (embed.type === 'link') {
const linkChannel = guild.channels.find(ch => ch.name === 'general-links');
if (linkChannel) linkChannel.send(embed.url);
} else if (embed.type !== 'rich') {
const mediaChannel = guild.channels.find(ch => ch.name === 'media');
if (mediaChannel) mediaChannel.send(embed.url);
}
});
}
if (attachments) {
attachments.forEach((attachment) => {
const mediaChannel = guild.channels.find(ch => ch.name === 'attachments');
if (mediaChannel) mediaChannel.send(new Attachment(attachment.url));
});
}
};
module.exports = {
archiveMedia,
};