├── Events
├── Client
│ └── ready.js
└── Interactions
│ └── SlashCommands.js
├── index.js
├── Commands
├── Owner
│ └── ping.js
└── Public
│ ├── auto-flagged-words.js
│ ├── auto-spam-messages.js
│ ├── auto-spam-mentions.js
│ └── auto-bad-words.js
├── package.json
├── cmdloader
└── fileloader.js
├── handlers
├── cmdhandler.js
└── eventhandler.js
└── README.md
/Events/Client/ready.js:
--------------------------------------------------------------------------------
1 | const { loadCommands } = require("../../handlers/cmdhandler");
2 |
3 | module.exports = {
4 | name: "ready",
5 | once: true,
6 | execute(client) {
7 |
8 | loadCommands(client);
9 | console.log(`${client.user.username} is ready`);
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const Discord = require("discord.js");
2 | const { Collection } = require("discord.js");
3 |
4 | const client = new Discord.Client({
5 | intents: 3276799
6 | });
7 |
8 |
9 | const { loadEvents } = require("./handlers/eventhandler");
10 | client.events = new Collection();
11 | client.commands = new Collection();
12 |
13 | loadEvents(client);
14 |
15 | client.login("yourbottoken");
16 |
--------------------------------------------------------------------------------
/Commands/Owner/ping.js:
--------------------------------------------------------------------------------
1 | const Discord = require("discord.js")
2 | const { SlashCommandBuilder } = require ('@discordjs/builders')
3 |
4 | module.exports = {
5 | data : new SlashCommandBuilder ()
6 | .setName('ping')
7 | .setDescription('pong'),
8 |
9 | async execute(interaction, client) {
10 | interaction.reply({ content: `pong`, ephemeral: true })
11 | }
12 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "automod",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "deadlock",
10 | "license": "ISC",
11 | "dependencies": {
12 | "@discordjs/builders": "^1.3.0",
13 | "@discordjs/rest": "^1.3.0",
14 | "ascii-table": "^0.0.9",
15 | "discord.js": "^14.7.1"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/cmdloader/fileloader.js:
--------------------------------------------------------------------------------
1 | const { glob } = require("glob");
2 | const { promisify } = require("util");
3 | const proGlob = promisify(glob);
4 |
5 | async function loadFiles(dirName) {
6 | const Files = await proGlob(
7 | `${process.cwd().replace(/\\/g, "/")}/${dirName}/**/*.js`
8 | );
9 | Files.forEach((file) => delete require.cache[require.resolve(file)]);
10 | return Files;
11 | }
12 |
13 | module.exports = { loadFiles };
14 |
--------------------------------------------------------------------------------
/handlers/cmdhandler.js:
--------------------------------------------------------------------------------
1 | async function loadCommands(client) {
2 | const { loadFiles } = require("../cmdloader/fileloader");
3 | const ascii = require("ascii-table");
4 | const table = new ascii().setHeading("Commands", "Status");
5 |
6 | await client.commands.clear();
7 |
8 | let commandsArray = [];
9 |
10 | const Files = await loadFiles("Commands");
11 |
12 | Files.forEach((file) => {
13 | const command = require(file);
14 | client.commands.set(command.data.name, command);
15 |
16 | commandsArray.push(command.data.toJSON());
17 |
18 | table.addRow(command.data.name, "✔");
19 | });
20 |
21 | client.application.commands.set(commandsArray);
22 |
23 | return console.log(table.toString(), "\nCommands are loaded successfully");
24 | }
25 |
26 | module.exports = { loadCommands };
27 |
--------------------------------------------------------------------------------
/Events/Interactions/SlashCommands.js:
--------------------------------------------------------------------------------
1 | const { ChatInputCommandInteraction } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "interactionCreate",
5 | /**
6 | *
7 | * @param {ChatInputCommandInteraction} interaction
8 | */
9 |
10 | execute(interaction, client) {
11 | if (!interaction.isChatInputCommand()) return;
12 |
13 | const command = client.commands.get(interaction.commandName);
14 | if (!command)
15 | return interaction.reply({
16 | content: "This command is outdated",
17 | ephemeral: true,
18 | });
19 |
20 | if (command.developer && interaction.user.id !== "yourdiscordid")
21 | return interaction.reply({
22 | content: "This command is only available to developer",
23 | ephemeral: true,
24 | });
25 |
26 | command.execute(interaction, client);
27 | },
28 | };
29 |
--------------------------------------------------------------------------------
/handlers/eventhandler.js:
--------------------------------------------------------------------------------
1 | async function loadEvents(client) {
2 | const { loadFiles } = require("../cmdloader/fileloader");
3 | const ascii = require("ascii-table");
4 | const table = new ascii().setHeading("Events", "Status");
5 |
6 | await client.events.clear();
7 |
8 | const Files = await loadFiles("Events");
9 | Files.forEach((file) => {
10 | const event = require(file);
11 |
12 | const execute = (...args) => event.execute(...args, client);
13 | client.events.set(event.name, execute);
14 |
15 | if (event.rest) {
16 | if (event.once) client.rest.on(event.name, execute);
17 | else client.rest.on(event.name, execute);
18 | } else {
19 | if (event.once) client.once(event.name, execute);
20 | else client.on(event.name, execute);
21 | }
22 |
23 | table.addRow(event.name, "✔");
24 | });
25 |
26 | return console.log(table.toString(), "\nLoaded the events successfully");
27 | }
28 |
29 | module.exports = { loadEvents };
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Star
3 |
4 |
5 | # ⭐ Update 1.0.1 Includes:
6 |
7 | Added the ability to make the bot sends the alert message in **Commands/Public/`automod-bad-words.js`** when someone say a bad word, called by: "Sends Alert"
8 |
9 | # Discord AutoMod Bot
10 |
11 | # Installation
12 |
13 |
14 | Windows Installation
15 |
16 |
17 | 1. Install [Node.js](https://nodejs.org/en) [ 1.18+ ]
18 | 2. Install [Visual Studio Code](https://code.visualstudio.com/)
19 | ```bash
20 | 3. Download this Project
21 | 4. npm init
22 | 5. npm i discord.js@latest
23 | 6. npm i @discordjs/builders@1.3.0
24 | 7. npm i @discordjs/rest@1.3.0
25 | 8. npm i ascii-table@0.0.9
26 | . node .
27 | ```
28 |
29 | and done!
30 |
31 |
32 | # Be sure to change these!
33 |
34 | Add your Discord Account ID in `Commands > Public > AutoMod` commands [ **ALL OF THE THEM** ]
35 |
36 | ```js
37 | creatorId: `youraccountid`, // Replace it with your Discord Account ID
38 | ```
39 |
40 |
41 | Also be sure to change line `15` in `index.js` file
42 |
43 | if you don't change these it will not work!
44 |
45 | # How to get the `Uses AutoMod` badge on your Discord bot?
46 |
47 |
48 | To continue click here
49 |
50 |
51 | `1.` Use `/automod-bad-words` command `6` times.
52 |
53 | `2.` Use `/automod-flagged-words` command `1` time.
54 |
55 | `3.` Use `/automod-spam-mentions` command `1` time.
56 |
57 | `4.` Use `/automod-spam-messages` command `1` time.
58 |
59 | in `12` servers, basically `9` commands ran in each server = `108` and thats the requirement for the `Uses AutoMod` badge..
60 |
61 | **IT TAKES 12-16 HOURS TO SHOW THE BADGE IF YOU DID THE REQUIREMENTS ^ CORRECTLY**
62 | [Click Here For Example](https://imgur.com/a/4XUoiv2)
63 |
64 |
65 | ## ⚠ ⚠ WE DON'T RECOMMEND YOU USING FAKE SERVERS, use it at your on risk. ⚠ ⚠
66 |
--------------------------------------------------------------------------------
/Commands/Public/auto-flagged-words.js:
--------------------------------------------------------------------------------
1 | const { SlashCommandBuilder, EmbedBuilder } = require ('@discordjs/builders');
2 | const { PermissionsBitField } = require('discord.js');
3 |
4 | module.exports = {
5 | data: new SlashCommandBuilder()
6 | .setName('automod-flagged-words')
7 | .setDescription('Creates an automod rule for flagged words'),
8 |
9 |
10 | async execute (interaction , client) {
11 |
12 | if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages) && !interaction.member.roles.cache.some((r) => r.name === "Deletes")) { return interaction.reply({ content: "Seems like you don't have `manage_messages` intents or a role named `Deletes", ephemeral: true }) }
13 | const { guild} = interaction ;
14 | const rule = await guild.autoModerationRules.create(
15 | {
16 | name: `Prevent profanity and sexual content, slurs by ${client.user.username}`,
17 | creatorId: `487229623810129922`,
18 | enabled: true,
19 | eventType: 1,
20 | triggerType: 4,
21 | triggerMetadata:
22 | {
23 | presets : [1 , 2 , 3]
24 | },
25 | actions: [
26 | {
27 | type: 1,
28 | metadata: {
29 | channel: interaction.channel,
30 | durationSeconds: 10,
31 | customMessage: `This message was prevented by ${client.user.username} moderation`
32 | }
33 | }
34 | ]
35 |
36 | }).catch(async err => {
37 | console.log(err)
38 | })
39 |
40 | const embed = new EmbedBuilder()
41 | .setAuthor({name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL()})
42 | .setDescription(`**Your automod rule for \`Flagged Words\` has been created successfully**`)
43 | .setThumbnail(interaction.user.displayAvatarURL({dynamic: true}))
44 | .setColor(0x00FF00)
45 | .setFooter({text: `Created by: ${interaction.user.id}`, iconURL: interaction.user.avatarURL()})
46 | .setTimestamp();
47 |
48 | if (!rule) return;
49 | await interaction.deferReply({fetchReply : true})
50 | return await interaction.editReply({ embeds: [embed] })
51 |
52 | }
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/Commands/Public/auto-spam-messages.js:
--------------------------------------------------------------------------------
1 | const { SlashCommandBuilder, EmbedBuilder } = require ('@discordjs/builders');
2 | const { PermissionsBitField } = require('discord.js');
3 |
4 | module.exports = {
5 | data: new SlashCommandBuilder()
6 | .setName('automod-spam-messages')
7 | .setDescription('Creates an automated rule for spam messages'),
8 |
9 |
10 | async execute (interaction , client) {
11 |
12 | if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages) && !interaction.member.roles.cache.some((r) => r.name === "Deletes")) { return interaction.reply({ content: "Seems like you don't have `manage_messages` intents or a role named `Deletes", ephemeral: true }) }
13 |
14 | const {guild} = interaction;
15 | const rule = await guild.autoModerationRules.create(
16 | {
17 | name: `Prevent Spam messages by ${client.user.username}`,
18 | creatorId: `487229623810129922`,
19 | enabled: true,
20 | eventType: 1,
21 | triggerType: 3,
22 | triggerMetadata:
23 | {
24 |
25 | },
26 | actions: [
27 | {
28 | type: 1,
29 | metadata: {
30 | channel: interaction.channel,
31 | durationSeconds: 10,
32 | customMessage: `This message was prevented by ${client.user.username} moderation`
33 | }
34 | }
35 | ]
36 |
37 | }).catch(async err => {
38 |
39 | console.log(err)
40 | })
41 |
42 | const embed = new EmbedBuilder()
43 |
44 | .setAuthor({name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL()})
45 | .setDescription(`**Your automod rule for \`spam messages\` has been created successfully**`)
46 | .setThumbnail(interaction.user.displayAvatarURL({dynamic: true}))
47 | .setColor(0x00FF00)
48 | .setFooter({text: `Created by: ${interaction.user.id}`, iconURL: interaction.user.avatarURL()})
49 | .setTimestamp();
50 |
51 |
52 | if (!rule) return;
53 | await interaction.deferReply({fetchReply : true })
54 | return await interaction.editReply({ embeds: [embed] })
55 |
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/Commands/Public/auto-spam-mentions.js:
--------------------------------------------------------------------------------
1 | const { SlashCommandBuilder, EmbedBuilder } = require ('@discordjs/builders');
2 | const { PermissionsBitField } = require('discord.js');
3 |
4 | module.exports = {
5 | data: new SlashCommandBuilder()
6 | .setName('automod-spam-mentions')
7 | .setDescription('Creates an automated rule for auto mentions')
8 | .addIntegerOption(option => option.setName('spam-mention').setDescription('Add the number to remove messages from suspected spammers!').setRequired(true)),
9 |
10 | async execute (interaction , client) {
11 | if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages) && !interaction.member.roles.cache.some((r) => r.name === "Deletes")) { return interaction.reply({ content: "Seems like you don't have `manage_messages` intents or a role named `Deletes", ephemeral: true }) }
12 |
13 | const {guild , options} = interaction;
14 | const number = options.getInteger('spam-mention')
15 |
16 | const rule = await guild.autoModerationRules.create(
17 | {
18 | name: `Prevent spam mentions by ${client.user.username}`,
19 | creatorId: `487229623810129922`,
20 | enabled: true,
21 | eventType: 1,
22 | triggerType: 5,
23 | triggerMetadata:
24 | {
25 | mentionTotalLimit: number
26 | },
27 | actions: [
28 | {
29 | type: 1,
30 | metadata: {
31 | channel: interaction.channel,
32 | durationSeconds: 10,
33 | customMessage: `This message prevented by ${client.user.username} auto moderation`
34 | }
35 | }
36 | ]
37 |
38 | }).catch(async err => {
39 |
40 | console.log(err)
41 |
42 | })
43 |
44 | const embed = new EmbedBuilder()
45 |
46 | .setAuthor({name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL()})
47 | .setDescription(`**Your automod rule for \`Spam Mentions\` has been created successfully**`)
48 | .setThumbnail(interaction.user.displayAvatarURL({dynamic: true}))
49 | .setColor(0x00FF00)
50 | .setFooter({text: `Created by: ${interaction.user.id}`, iconURL: interaction.user.avatarURL()})
51 | .setTimestamp();
52 |
53 |
54 | if (!rule) return;
55 | await interaction.deferReply({ fetchReply : true })
56 | return await interaction.editReply({ embeds: [embed] })
57 |
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/Commands/Public/auto-bad-words.js:
--------------------------------------------------------------------------------
1 | const Discord = require("discord.js")
2 | const { PermissionsBitField } = require('discord.js');
3 | const { SlashCommandBuilder, EmbedBuilder } = require ('@discordjs/builders');
4 |
5 | module.exports = {
6 | data: new SlashCommandBuilder()
7 | .setName('automod-bad-words')
8 | .setDescription('Creates an automated rule for bad words')
9 | .addStringOption(option => option.setName('word').setDescription('Add the word to be removed from the automod').setRequired(true)),
10 |
11 | async execute (interaction, client) {
12 |
13 | if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages) && !interaction.member.roles.cache.some((r) => r.name === "Deletes")) { return interaction.reply({ content: "Seems like you don't have `manage_messages` intents or a role named `Deletes`", ephemeral: true }) }
14 |
15 | const {options , guild} = interaction;
16 | const word = options.getString('word');
17 | const rule = await guild.autoModerationRules.create({
18 | name: `Prevent bad word by ${client.user.username}`,
19 | creatorId: `487229623810129922`,
20 | enabled: true,
21 | eventType: 1,
22 | triggerType: 1,
23 | triggerMetadata: {
24 | keywordFilter: [`${word}`]
25 | },
26 | actions: [
27 | {
28 | type: 1,
29 | metadata: {
30 | warningMessage: `Please stop using bad language`
31 | }
32 | },
33 | {
34 | type: 2,
35 | metadata: {
36 | channel: interaction.channel,
37 | durationSeconds: 10,
38 | customMessage: `This message was prevented by ${client.user.username} auto moderation`
39 | }
40 | }
41 | ]
42 | }).catch(async err => {
43 | console.log(err)
44 | })
45 | const embed = new EmbedBuilder()
46 | .setAuthor({name: `${interaction.guild.name}`, iconURL: interaction.guild.iconURL()})
47 | .setDescription(`**Your automod rule for \`Bad Words\` has been created successfully**`)
48 | .setThumbnail(interaction.user.displayAvatarURL({dynamic: true}))
49 | .setColor(0x00FF00)
50 | .setFooter({text: `Setted by: ${interaction.user.id}`, iconURL: interaction.user.avatarURL()})
51 | .setTimestamp();
52 |
53 | await interaction.deferReply({ fetchReply: true })
54 |
55 | return await interaction.editReply({ embeds: [embed] })
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------