A script was created to automatically delete messages from offline users during chat sessions on Discord. If an offline user attempted to chat, their message would be deleted, and a notification would be sent to the console indicating that offline chat was detected.
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('message', message => {
let member = message.member;
let status = member.user.presence.status;
let args = message.content.trim().split(' ');
if(args[0]){
if(status === "offline") {
message.delete();
}
}
bot.on('messageDelete', (msg, status) => {
if(status === "offline"){
console.log('Offline user chat detected.')
}
}
Despite the efforts put into the messageDelete
section, it was not functioning as expected, mainly due to issues with the variable status
.
The question remains - how can the other handler variables be retrieved and implemented properly?