-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 1.26 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
// Dependencies
const { Client, Intents } = require("discord.js")
// Variables
const bot = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_MEMBERS ] })
var stopMentioning = {
token: "",
maxPings: 5,
userPings: {}
}
// Main
bot.on("ready", ()=>{
bot.user.setActivity("Watching for mentioners.")
console.log("StopMentioning is running.")
})
bot.on("message", (message)=>{
if(!message.guild) return
if(message.author.bot) return
const userID = message.author.id
const mentions = message.mentions.users
if(!stopMentioning.userPings[userID]) stopMentioning.userPings[userID] = 0
mentions.size > 0 ? stopMentioning.userPings[userID]++ : stopMentioning.userPings[userID] = 0
if(stopMentioning.userPings[userID] >= stopMentioning.maxPings){
message.channel.send(`Potential spam mention has been detected because of <@${userID}>. The channel has been locked down.`)
message.channel.permissionOverwrites.create(message.guild.roles.everyone, { SEND_MESSAGES: false })
stopMentioning.userPings[userID] = 0
}
})
bot.login(stopMentioning.token)