better message event error handling

master
Kit Kasune 3 years ago
parent 88ae4fa583
commit 663e0a69f4
  1. 4
      events/messageCreate.js
  2. 4
      events/messageDelete.js
  3. 6
      events/messageUpdate.js

@ -11,11 +11,11 @@ const Monitors = require('../models/monitor');
const channelTypes = ["GUILD_MESSAGE", "DM", "GUILD_NEWS_THREAD", "GUILD_PRIVATE_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_NEWS", "GROUP_DM", "GUILD_STORE", "GUILD_TEXT"];
module.exports = async (client, message) => {
if (message.author.bot) {return undefined;}
if (message.partial) {await message.fetch();}
if (message.channel.partial) {await message.channel.fetch();}
if (!message.author || message.author.bot) {return undefined;}
if (!channelTypes.includes(message.channel.type)) {return undefined;}
//if (message.channel.type == "text") {if (settings[message.guild.id]) {prefix = settings[message.guild.id].prefix;};};

@ -3,6 +3,10 @@ const Discord = require('discord.js');
const channelTypes = ["GUILD_MESSAGE", "DM", "GUILD_NEWS_THREAD", "GUILD_PRIVATE_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_NEWS", "GROUP_DM", "GUILD_STORE"];
module.exports = async (client, message) => {
if (message.partial) {await message.fetch().catch(() => {});}
if (message.channel.partial) {await message.channel.fetch().catch(() => {});}
if (!message.author) {return;}
if (!channelTypes.includes(message.channel.type)) {return;}
if (!message.guild) {return;}
//if (!Object.keys(snipe.delete).includes(message.guild.id)) {snipe.delete[message.guild.id] = {};};

@ -3,8 +3,12 @@ const Discord = require('discord.js');
const channelTypes = ["GUILD_MESSAGE", "DM", "GUILD_NEWS_THREAD", "GUILD_PRIVATE_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_NEWS", "GROUP_DM", "GUILD_STORE"];
module.exports = async (client, oldM, newM) => {
if (oldM.partial) {await oldM.fetch().catch(() => {});}
if (newM.partial) {await newM.fetch().catch(() => {});}
if (oldM.channel.partial) {await oldM.channel.fetch().catch(() => {});}
if (!channelTypes.includes(oldM.channel.type)) {return;};
if (oldM.author.bot) {return;}
if (!oldM.author || oldM.author.bot) {return;}
if (oldM.deleted) {return;}
//if (!Object.keys(snipe.edit).includes(oldM.guild.id)) {snipe.edit[oldM.guild.id] = {};};
//snipe.edit[oldM.guild.id][oldM.channel.id] = {old: oldM, cur: newM};

Loading…
Cancel
Save