This repository was archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdmforward.js
More file actions
27 lines (26 loc) · 1.93 KB
/
dmforward.js
File metadata and controls
27 lines (26 loc) · 1.93 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
const { Client, Message } = require("discord.js");
module.exports = async (message, client) => {
if (client.dmForwardBlacklist._content.includes(message.author.id) || message.author.bot) return;
if (client.games.some(x => x === message.author.tag)) return;
const channel = client.channels.cache.get(client.config.mainServer.channels.staffLogs);
const pcCreatorServer = client.guilds.cache.get(client.config.mainServer.id);
const guildMemberObject = await pcCreatorServer.members.fetch(message.author.id);
const memberOfPccs = !!guildMemberObject
const embed = new client.embed()
.setTitle('Forwarded DM Message')
.setAuthor(`${message.author.tag} (${message.author.id})`, message.author.displayAvatarURL({ format: 'png', dynamic: true}))
.setColor(3971825)
.addField('Message Content', message.content.length > 1024 ? message.content.slice(1021) + '...' : message.content + '\u200b')
.setTimestamp(Date.now());
let messageAttachmentsText = '';
message.attachments.forEach(attachment => {
if (!embed.image && ['png', 'jpg', 'webp', 'gif', 'jpeg'].some(x => attachment.name.endsWith(x))) embed.setImage(attachment.url);
else messageAttachmentsText += `[${attachment.name}](${attachment.url})\n`;
});
if (messageAttachmentsText.length > 0) embed.addField('Message Attachments', messageAttachmentsText.trim());
embed
.addField('User', `<@${message.author.id}>`)
.addField('Connections', `:small_blue_diamond: Message sender **${guildMemberObject ? 'is' : ' is not'}** on the **${pcCreatorServer.name}** Discord server${memberOfPccs ? `\n:small_blue_diamond: Roles on the PC Creator server: ${guildMemberObject.roles.cache.filter(x => x.id !== pcCreatorServer.roles.everyone.id).map(x => '**' + x.name + '**').join(', ')}` : ''}`)
channel.send({embeds: [embed]})
channel.send({content: client.config.eval.whitelist.map(x => `<@${x}>`).join(', ')});
};