Compare commits
2 Commits
c788a1ff04
...
13fb466144
Author | SHA1 | Date | |
---|---|---|---|
13fb466144 | |||
606aa4b72f |
@ -71,12 +71,11 @@ var commands = module.exports = [
|
|||||||
{
|
{
|
||||||
name: "user",
|
name: "user",
|
||||||
description: "can i not leave some obvious descriptions blank?",
|
description: "can i not leave some obvious descriptions blank?",
|
||||||
type: "USER",
|
type: "USER"
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
exec: async i => {
|
exec: async i => {
|
||||||
var user = i.options.getUser("user");
|
var user = i.options.getUser("user") || i.user;
|
||||||
var au = user.avatarURL({size:4096, dynamic: true});
|
var au = user.avatarURL({size:4096, dynamic: true});
|
||||||
var an = au.split('/').pop(); an = an.substring(0, an.indexOf('?'));
|
var an = au.split('/').pop(); an = an.substring(0, an.indexOf('?'));
|
||||||
i.reply({files: [{attachment: au, name: an}], embeds: [{
|
i.reply({files: [{attachment: au, name: an}], embeds: [{
|
||||||
|
25
pinboard.js
25
pinboard.js
@ -53,26 +53,13 @@ client.on("messageReactionAdd", async (reaction, user) => {
|
|||||||
|
|
||||||
|
|
||||||
async function doThing(message, user) {
|
async function doThing(message, user) {
|
||||||
// cache avatar because discord doesn't keep it if they change it
|
var avatarURL = message.author.avatarURL({dynamic: true}) || message.author.defaultAvatarURL;
|
||||||
var avatarURL = message.author.avatarURL({dynamic: true});
|
var avatarName = avatarURL.split('/').pop();
|
||||||
if (avatarURL) {
|
|
||||||
let afn = avatarURL.split('/').pop();
|
|
||||||
let lapath = config.data_dir + "avatars/" + afn;
|
|
||||||
if (!fs.existsSync(lapath)) {
|
|
||||||
try {
|
|
||||||
(await fetch(avatarURL)).body.pipe(fs.createWriteStream(lapath));
|
|
||||||
} catch (error) {
|
|
||||||
console.error("avatar download", error.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
avatarURL = `${config.base_uri}/avatars/${afn}`
|
|
||||||
} else avatarURL = message.author.defaultAvatarURL;
|
|
||||||
|
|
||||||
let imageCandidate = message.attachments.find(a => [".png",".jpg",".jpeg",".webp",".gif"].some(e => a.url.toLowerCase().endsWith(e)));
|
let imageCandidate = message.attachments.find(a => [".png",".jpg",".jpeg",".webp",".gif"].some(e => a.url.toLowerCase().endsWith(e)));
|
||||||
if (imageCandidate) imageCandidate["will be used for the image of the embed"] = true;
|
if (imageCandidate) imageCandidate["will be used for the image of the embed"] = true;
|
||||||
else imageCandidate = message.embeds.find(e => e.type == 'image');
|
else imageCandidate = message.embeds.find(e => e.type == 'image');
|
||||||
let embed = new Discord.MessageEmbed()
|
let embed = new Discord.MessageEmbed()
|
||||||
.setAuthor(message.member?.displayName || message.author.username, avatarURL)
|
.setAuthor(message.member?.displayName || message.author.username, `attachment://${avatarName}`)
|
||||||
.setDescription(message.content)
|
.setDescription(message.content)
|
||||||
.setImage(imageCandidate?.url)
|
.setImage(imageCandidate?.url)
|
||||||
.setFooter(`Pinned by ${message.guild.members.resolve(user)?.displayName || user.username}`)
|
.setFooter(`Pinned by ${message.guild.members.resolve(user)?.displayName || user.username}`)
|
||||||
@ -80,7 +67,11 @@ async function doThing(message, user) {
|
|||||||
.setColor(message.member?.roles.color?.color);
|
.setColor(message.member?.roles.color?.color);
|
||||||
let attachments = message.attachments.filter(a => !a["will be used for the image of the embed"]).map(a => `[${a.name}](${a.url})`).join('\n');
|
let attachments = message.attachments.filter(a => !a["will be used for the image of the embed"]).map(a => `[${a.name}](${a.url})`).join('\n');
|
||||||
if (attachments) embed.addField("Attachments", attachments);
|
if (attachments) embed.addField("Attachments", attachments);
|
||||||
return (await client.channels.fetch(config.archive_channel))?.send({content: `https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`, embeds:[embed]});
|
return (await client.channels.fetch(config.archive_channel))?.send({
|
||||||
|
content: `https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`,
|
||||||
|
files: [{attachment: avatarURL, name: avatarName}],
|
||||||
|
embeds:[embed]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user