diff --git a/src/config.js b/src/config.js index 336dde5..1df53d7 100644 --- a/src/config.js +++ b/src/config.js @@ -9,7 +9,8 @@ module.exports = { "webhooks": { "welcome": process.env.WEBHOOK_WELCOME.split("/"), "error": process.env.WEBHOOK_ERROR.split("/"), - "ddp": process.env.WEBHOOK_DDP.split("/") + "ddp": process.env.WEBHOOK_DDP.split("/"), + "pinboard": process.env.WEBHOOK_PINBOARD.split("/") }, "opID": "281134216115257344", diff --git a/src/local_events.js b/src/local_events.js index 3fe3db1..83645d5 100644 --- a/src/local_events.js +++ b/src/local_events.js @@ -25,4 +25,8 @@ dClient.on("voiceStateUpdate", async function(oldState, newState){ dClient.on("emojiDelete", async function(emoji){ if (emoji.guild.id == config.guildID) this.emit("local_emojiDelete", emoji); +}); +dClient.on("messageReactionAdd", async function(messageReaction, user){ + if (messageReaction.message.guild.id == config.guildID) + this.emit("local_messageReactionAdd", messageReaction, user); }); \ No newline at end of file diff --git a/src/misc.js b/src/misc.js index d419d64..20d5442 100755 --- a/src/misc.js +++ b/src/misc.js @@ -87,6 +87,44 @@ // persistent emojis -dClient.on("local_emojiDelete", emoji => { - emoji.guild.emojis.create(emoji.url, emoji.name); -}); \ No newline at end of file +dClient.on("local_emojiDelete", async emoji => { + await emoji.guild.emojis.create(emoji.url, emoji.name); +}); + + +// pinboard +(async function(){ + var webhook = new Discord.WebhookClient(config.webhooks.pinboard[0], config.webhooks.pinboard[1]); + dClient.on("local_messageReactionAdd", async (messageReaction, user) => { + if (!(messageReaction.emoji.name == "📌" || messageReaction.emoji.name == "📍")) return; + if (!(user.id == messageReaction.message.author.id || messageReaction.message.guild.members.get(user.id).hasPermission('MANAGE_MESSAGES'))) return;// if message is theirs or user is mod + var message = messageReaction.message; + await webhook.send(`https://discordapp.com/channels/${message.guild.id}${message.channel.id}/${message.id}`, {embeds:[{ + color: (message.member && message.member.displayColor) || undefined, + author: { + name: (message.member && message.member.displayName) || message.author.username, + icon_url: message.author.avatarURL({format:'png'}) + }, + description: message.content, + timestamp: message.createdAt, + image: (message.attachments.first() && message.attachments.first().width) ? {url:message.attachments.first().url} : undefined, + footer: { + text: `#${message.channel.name}` + } + }]}); + }); +})(); + + + + + + + + + + + + + +