I’m probably not understanding but I would like someone to help me, I’m doing that if someone gives a mention to a user, read if they have afk set in the database so that they return it, I’m supposed to have already defined it in Async execute (message)
My code
const afkModel = require("../../Models/Afk");
const { Message} = require('discord.js')
module.exports = {
name: "messageCreate",
async execute(message, client, guild) {
if (message.author.bot || !message.guild) return;
let data = await afkModel.findOne({ Guild: message.guild.id, UserID: message.author.id })
if(!data) return;
if (data.Afk) {
if(!data) return;
data.Afk = false;
data.save();
}
return;
}};
const taggedMembers = mentions.users.map(msg => msg.id);
if (taggedMembers.length > 0) {
taggedMembers.forEach(m => {
afkModel.findOne({ Guild: guild.id, UserID: m }, async (err, data) => {
if(!data) return;
if (data.Afk) {
if(!data) return;
message.reply(`This user is currently Afk. nReason: ${data.Reason || "None provided."}`);
}
return;
})
})
}
`
My error
const taggedMembers = message.mentions.users.map(msg => msg.id);
^
ReferenceError: message is not defined
at Object.<anonymous> (/Users/joshuaacosta/Desktop/Sayu/Events/Messages/afk.js:20:31)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at loadEvents (/Users/joshuaacosta/Desktop/Sayu/Handlers/eventHandler.js:11:19)
at /Users/joshuaacosta/Desktop/Sayu/index.js:41:5
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I would like to know if I am doing wrong and what should I add so that my command works when a user mentanother user and if he has afk he responds with a mention replY
