Compare commits
No commits in common. "13fb466144c703410483c446ecd0786a959c3abd" and "c788a1ff04e1a6ba76d746a1ab23172fdb7a02ce" have entirely different histories.
13fb466144
...
c788a1ff04
@ -71,11 +71,12 @@ 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") || i.user;
|
var user = i.options.getUser("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,13 +53,26 @@ client.on("messageReactionAdd", async (reaction, user) => {
|
|||||||
|
|
||||||
|
|
||||||
async function doThing(message, user) {
|
async function doThing(message, user) {
|
||||||
var avatarURL = message.author.avatarURL({dynamic: true}) || message.author.defaultAvatarURL;
|
// cache avatar because discord doesn't keep it if they change it
|
||||||
var avatarName = avatarURL.split('/').pop();
|
var avatarURL = message.author.avatarURL({dynamic: true});
|
||||||
|
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, `attachment://${avatarName}`)
|
.setAuthor(message.member?.displayName || message.author.username, avatarURL)
|
||||||
.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}`)
|
||||||
@ -67,11 +80,7 @@ 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({
|
return (await client.channels.fetch(config.archive_channel))?.send({content: `https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`, embeds:[embed]});
|
||||||
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