Skip to content

Commit

Permalink
fixed automod
Browse files Browse the repository at this point in the history
  • Loading branch information
vKxni committed Feb 15, 2022
1 parent d93b0f6 commit bc44770
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/commands/Admin/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ module.exports.ownerOnly = {
*/
module.exports.run = async (interaction, utils) => {
try {
const ping = Date.now() - interaction.createdTimestamp;
const ping = Date.now() - interaction.createdTimestamp

if (ping >= 500) {
var stat = "🔴";
} else {
stat = "🟢";
}



const embed = new MessageEmbed()
.setTitle("Debug")
.setDescription(
Expand Down
26 changes: 16 additions & 10 deletions src/events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ module.exports.run = async (message) => {
// If the Guild has no setup done, dont do anything/ignore it.
if (!check) return;
const owner = await message.guild.fetchOwner();
if(message.author.id !== owner) return;
if(message.author.id === owner) return;

// If the user has a higher / or the same role as the bot, return
if (message.author.roles.highest.position >= message.guild.me.roles.highest.position) return;

// TODO: return members with a certain role (setup mod role)
if (message.member.roles.highest.position >= message.guild.me.roles.highest.position) return;

if (check) {
// if(message.author.bot) return;

if (array.some((word) => message.content.toLowerCase().includes(word))) {
message.delete();

// Time the user for 1h after sending a banned word/link.
const member = message.guild.members.cache.get(message.author);
const timeout = await message.member.timeout(3600000);

const embed = new MessageEmbed()
.setTitle(`${emojis.error} Scam detected`)
.setColor("#ff0000")
Expand Down Expand Up @@ -79,10 +81,7 @@ module.exports.run = async (message) => {
webhookClient.send({ embeds: [embed] });
}

// Timeout the User after sending the word.
const member = message.guild.members.cache.get(message.author);
const timeout = await message.member.timeout(43200000);


const embed2 = new MessageEmbed()
.setTitle(`${emojis.error} Scam detected`)
.setDescription(
Expand All @@ -99,7 +98,14 @@ module.exports.run = async (message) => {
})
.setTimestamp();

message.author.send({ embeds: [embed2] });
try {
await message.author.send({ embeds: [embed2] });
} catch(error) {
message.channel.send({ content: `Could not send DMs to the User, they are closed.`})
console.log(error)
return;
}

}
}
} catch (err) {
Expand Down

0 comments on commit bc44770

Please sign in to comment.