This snippets works with a slash command `/report`, this allowed the users in your server to report another user for breaking the rules etc. When a user uses this command they will be send an ephemeral message saying they staff received their report. For this app to work you'll need to make a slash command in the slash command builder (https://autocode.com/tools/discord/command-builder/). Make 2 options; first --> (user) user, second --> (string) reason.
// For this app to work you'll need to make a slash command in the slash command builder (https://autocode.com/tools/discord/command-builder/).
// Make 2 options; first --> (user) user, second --> (string) reason.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const event = context.params.event;
const msg = event.content;
const { guild_id, channel_id } = event;
let user = event.data.options[0].value;
let reason = event.data.options[1].value;
await lib.discord.channels['@0.2.2'].messages.create({
channel_id: process.env.LOGCHANNEL,
content: `<@&${process.env.STAFF}>`,
embeds: [{
type: 'rich',
title: 'New report',
description: '',
color: 0xffffff,
fields: [
{
name: 'Reporter',
value: `<@${event.member.user.id}>`,
inline: true,
},
{
name: 'User',
value: `<@${user}>`,
inline: true,
},
{
name: 'Reason',
value: `${reason}`,
inline: false,
}
],
timestamp: event.received_at,
}],
});
await lib.discord.interactions['@0.0.0'].followups.ephemeral.create({
token: context.params.event.token,
content: ``,
embeds: [{
title: `Report Reveiced :thumbsup:`,
description: `<@${event.member.user.id}> Thank you for your report, I've send it to the server staff to take a look into this. this will stay annonymous so you don't have to worry about a single thing.`,
color: 0xffffff
}]
});