Alright, I'm trying to pass the client
to the guildDelete
event, I've got this inside my eventLoader.js
file.
const reqEvent = (event) => require(`../events/${event}`);
module.exports = client => {
client.on('guildDelete', (...args) => reqEvent('guildDelete')(client, ...args));
};
And this is in my guildDelete.js
event file.
const dataP = require('../functions/dataProvider.js');
module.exports = (client, guild) => {
client.serConf.delete(guild.id);
dataP.dbDeleteConfs(guild.id, guild.name);
};
This is the dbDeleteConfs function from my dataProvider.js
file.
/* This deletes the config data from the confs.db */
async function dbDeleteConfs(guildId, guildName){
try {
confs.removeAsync(guildId);
console.log(`${guildName} successfully removed. // guildDelete event`);
} catch (e) {
console.log(e);
}
}
When ever I remove my bot from a guild, it throws this...
New Guild SkyNET added to database.
SkyNET successfully removed.
(node:8768) DiscordAPIError: Missing Access
at item.request.gen.end (C:\Users\YorkAARGH\Documents\GitHub\Custodian\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:68:65)
at then (C:\Users\YorkAARGH\Documents\GitHub\Custodian\node_modules\snekfetch\src\index.js:183:21)
at process._tickCallback (internal/process/next_tick.js:109:7)
(node:8768) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitWarning (internal/process/promises.js:69:15)
at emitPendingUnhandledRejections (internal/process/promises.js:86:11)
at process._tickCallback (internal/process/next_tick.js:110:7)
The DiscordAPIError: Missing Access
is typically to do with using something from the guild, but other than grabbing the id and guild name, I don't appear to be doing anything with it.
I would like to note that it deletes the data out of the collection (client.serconf = new Discord.Collection();
from my main file.), but not the actual confs.db file, which makes me think it's my function, but when I place the function directly into the guildDelete
event it still throws the same error.