Allows users with a trusted role to flag comments by reacting with the ❗ emoji and flagged messages are sent to a specific channel.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
const { guild_id, channel_id, message_id } = event;
// ** DEV ** Change variables
const emoji = '❗'
const trustedRoleId = '12345'
const modChannelId = '12345'
// Is this our emoji?
if (event.emoji.name !== emoji) return
// Has the user got the role ID?
if (!event.member.roles.includes(trustedRoleId)) return
// Get original message
const message = await lib.discord.channels['@0.2.0'].messages.retrieve({
channel_id, message_id,
});
// Send warning to mod channel
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: modChannelId,
content: `${event.member.user.username} has reported a comment`,
embed: {
title: `⚠ Message by ${message.author.username} ⚠`,
description: `${message.content}`,
url: `https://discord.com/channels/${guild_id}/${channel_id}/${message_id}`
}
});