This commit is contained in:
Erik 2021-06-20 01:32:43 +03:00
parent e0786f0fbd
commit c7f82f458c
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16

View File

@ -150,10 +150,6 @@ class Modmail {
if (!cache._channels) cache._channels = {}; if (!cache._channels) cache._channels = {};
cache._channels[author.id] = channel; cache._channels[author.id] = channel;
pastModmail.push({ author: author.id, content, timestamp: Date.now(), isReply: false });
if (!this.updatedThreads.includes(author.id)) this.updatedThreads.push(author.id);
this.queue.push(author.id);
const embed = { const embed = {
footer: { footer: {
text: member.id text: member.id
@ -170,10 +166,17 @@ class Modmail {
timestamp: new Date() timestamp: new Date()
}; };
if (message.attachments.size) embed.fields.push({ const attachments = message.attachments.map((att) => att.url);
name: '__Attachments__', if (message.attachments.size) {
value: message.attachments.map((att) => att.url).join('\n').substring(0, 1000) embed.fields.push({
}); name: '__Attachments__',
value: attachments.join('\n').substring(0, 1000)
});
}
pastModmail.push({ attachments, author: author.id, content, timestamp: Date.now(), isReply: false });
if (!this.updatedThreads.includes(author.id)) this.updatedThreads.push(author.id);
this.queue.push(author.id);
await channel.send({ embed }).catch((err) => { await channel.send({ embed }).catch((err) => {
this.client.logger.error(`channel.send errored:\n${err.stack}\nContent: "${content}"`); this.client.logger.error(`channel.send errored:\n${err.stack}\nContent: "${content}"`);
@ -209,6 +212,7 @@ class Modmail {
parent: this.newMail.id parent: this.newMail.id
}); });
// Start with user info embed
const embed = { const embed = {
author: { name: user.tag }, author: { name: user.tag },
thumbnail: { thumbnail: {
@ -233,9 +237,9 @@ class Modmail {
`**Roles:** ${member.roles.cache.map((r) => `<@&${r.id}>`).join(' ')}`, `**Roles:** ${member.roles.cache.map((r) => `<@&${r.id}>`).join(' ')}`,
inline: false inline: false
}); });
await channel.send({ embed }); await channel.send({ embed });
// Load in context
const len = history.length; const len = history.length;
for (let i = context < len ? context : len; i > 0; i--) { for (let i = context < len ? context : len; i > 0; i--) {
const entry = history[len - i]; const entry = history[len - i];
@ -270,6 +274,7 @@ class Modmail {
}); });
await channel.send({ embed }); await channel.send({ embed });
} }
this.client.cache.channels[user.id] = channel.id; this.client.cache.channels[user.id] = channel.id;
@ -354,8 +359,8 @@ class Modmail {
if (sent.error) return sent; if (sent.error) return sent;
embed.author = { if (anon) embed.author = {
name: author.tag, name: `${author.tag} (ANON)`,
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
icon_url: author.displayAvatarURL({ dynamic: true }) icon_url: author.displayAvatarURL({ dynamic: true })
}; };