Easy way to prevent any users to send token grabber links. Checks if the message that was sent contains any known token grabber Links. If it does, it deletes the message, sends a warning in the chat and assigns a muted role. If you find Bugs or if something is not working, contact me! Chillihero#0001
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
//usermessage
const messageContent = context.params.event.content;
//send a request to the MessageCheck API to check if string contains grabber Links
let isMessageTokengrabber = await lib.chillihero['tokengrabber-check'][
'@release'
].checkAll({
message: messageContent,
});
//Lets define some variables
//channel Id of the sent message
const channelID = context.params.event.channel_id;
//Author ID of the User that sent the message
const authorID = context.params.event.author.id;
//Name of the Author
const authorName = context.params.event.author.username;
//Discriminator of the Author
const authorDiscriminator = context.params.event.author.discriminator;
//ID of the guild
const guildID = context.params.event.guild_id;
//timeout in days (max. 28)
//let timeoutDays = 28;
let timeoutDays = process.env.PHISHING_TIMEOUT;
let timeout = timeoutDays * 24 * 60 * 60;
//ID of the channel, you want to log the incident in
const logChannelID = process.env.LOG_CHANNEL_ID;
//Timestamp of the creation
const timestamp = context.params.event.timestamp;
//define a role that should get pinged if someone with a higher role then the bot sends phishing links.
const staffRoleID = null; //if null no one gets pinged
//If Request says yes it does do something
if (isMessageTokengrabber === true) {
//Here you can Do whatever you want
//lets timeout the user
try {
await lib.discord.guilds['@0.2.2'].members.timeout.update({
user_id: `${authorID}`,
guild_id: `${guildID}`,
communication_disabled_until_seconds: timeout,
reason: `Phished Account`,
});
} catch (e) {
console.log(`ERROR: `, e);
let staffMention = staffRoleID !== null ? `<@&${staffRoleID}>` : ``;
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${logChannelID}`,
content: `Couldn't timeout <@${authorID}> since their Role is higher then mine! ${staffMention}`,
});
}
//we delete the message from the user
await lib.discord.channels['@0.1.2'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${channelID}`,
});
//message in chat that the account is used to scam people
await lib.discord.channels['@0.2.2'].messages.create({
channel_id: `${channelID}`,
content: `<@${authorID}> your account is used to scam people.\n Please Change your Password and activate 2FA.\n If you want to get unmuted, please open a ticket!`,
});
//Log, that what user sent what message into what channel
await lib.discord.channels['@0.2.2'].messages.create({
channel_id: `${logChannelID}`,
content: `content`,
embeds: [
{
type: 'rich',
title: `⚠️TOKENGRABBER DETECTED⚠️`,
description: `<@${authorID}> sent a message containing a tokengrabber link and got automatically timeouted for ${timeoutDays} days!`,
color: 0xff0000,
fields: [
{
name: `Message:`,
value: `\`${messageContent}\``,
},
],
author: {
name: `${authorName}#${authorDiscriminator}`,
},
},
],
});
}