mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 21:14:15 +02:00
feat(arabot): add attachments to suggestions
This commit is contained in:
parent
6f276d5083
commit
d6a796eebd
@ -44,13 +44,36 @@ export class Suggestions extends Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const attachments: string[] = [];
|
||||||
|
let attachmentsString = '';
|
||||||
|
|
||||||
|
message.attachments.forEach((attachment) => {
|
||||||
|
attachments.push(attachment.url);
|
||||||
|
attachmentsString += `${attachment.url}\n`;
|
||||||
|
});
|
||||||
|
|
||||||
const suggestion = new EmbedBuilder()
|
const suggestion = new EmbedBuilder()
|
||||||
.setColor('#FFFFFF')
|
.setColor('#FFFFFF')
|
||||||
.setAuthor({ name: `Suggestion from ${message.author.tag}:`, iconURL: `${message.author.displayAvatarURL()}` })
|
.setAuthor({ name: `Suggestion from ${message.author.tag}:`, iconURL: `${message.author.displayAvatarURL()}` })
|
||||||
.setDescription(message.content)
|
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
const sent = await mailbox.send({ embeds: [suggestion], content: message.author.toString() });
|
if (message.content.length > 0) {
|
||||||
|
suggestion.setDescription(message.content);
|
||||||
|
} else if (attachments.length > 0) {
|
||||||
|
suggestion.setFields({ name: 'Attachments', value: attachmentsString });
|
||||||
|
} else {
|
||||||
|
await message.delete();
|
||||||
|
await message.author.send({
|
||||||
|
content: 'There was an error sending your suggestion, please try again later or contact the devs!',
|
||||||
|
}).catch(() => {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sent = await mailbox.send({
|
||||||
|
embeds: [suggestion],
|
||||||
|
content: message.author.toString(),
|
||||||
|
files: attachments,
|
||||||
|
});
|
||||||
await message.delete();
|
await message.delete();
|
||||||
|
|
||||||
await sent.react('👍');
|
await sent.react('👍');
|
||||||
@ -61,6 +84,7 @@ export class Suggestions extends Listener {
|
|||||||
await message.author.send({
|
await message.author.send({
|
||||||
content: 'Your suggestion has been sent!',
|
content: 'Your suggestion has been sent!',
|
||||||
embeds: [suggestion],
|
embeds: [suggestion],
|
||||||
|
files: attachments,
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user