Auto Mod Create Event not working

here is the event code. the output is nothing
const { EmbedBuilder, Events } = require('discord.js');
require('dotenv').config();
const logsSchema = require('../../Models/Logs');

module.exports = {
name: Events.AutoModerationRuleCreate,
on: true,
async execute(rule, client){
console.log("abc");
const guild = client.guilds.cache.get(rule.guild.id)
if (!guild) return;
console.log(guild.id);
const logChannelFind = await logsSchema.findOne({
GuildID: rule.guild.id
});
if (!logChannelFind) return;
console.log(logChannelFind);
const logChannel = client.channels.cache.get(logChannelFind.ChannelID);
const embed = new EmbedBuilder()
.setColor("Green")
.setTitle("Auto Moderation Rule Created")
try {
logChannel.send({ embeds: [embed] })
} catch (error) {
console.log(error);
};
}
}
const { EmbedBuilder, Events } = require('discord.js');
require('dotenv').config();
const logsSchema = require('../../Models/Logs');

module.exports = {
name: Events.AutoModerationRuleCreate,
on: true,
async execute(rule, client){
console.log("abc");
const guild = client.guilds.cache.get(rule.guild.id)
if (!guild) return;
console.log(guild.id);
const logChannelFind = await logsSchema.findOne({
GuildID: rule.guild.id
});
if (!logChannelFind) return;
console.log(logChannelFind);
const logChannel = client.channels.cache.get(logChannelFind.ChannelID);
const embed = new EmbedBuilder()
.setColor("Green")
.setTitle("Auto Moderation Rule Created")
try {
logChannel.send({ embeds: [embed] })
} catch (error) {
console.log(error);
};
}
}
2 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
PAdventures
PAdventuresOP2y ago
when i create a rule, nothing happens my bot does have the ManageGuild/Server permission i am going to be idle/offline for a while and will definitely be able to reply to messages sent <t:1681023600:R> probably not, ill add it 🤦 it works, thanks
Want results from more Discord servers?
Add your server