i have this error in my bot log
-(node:315) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at guildInvites.find.i (/app/server.js:477:46)
at Map.find (/rbd/pnpm-volume/e510aebc-aa8d-41e6-bdbe-632fceb24fc5/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/util/Collection.js:506:11)
at member.guild.fetchInvites.then.guildInvites (/app/server.js:477:33)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
(node:315) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 355)
and this is the code
const invites = {};
const wait = require('util').promisify(setTimeout);
client.on('ready', () => {
wait(1000);
client.guilds.forEach(g => {
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
});
member.guild.fetchInvites().then(guildInvites => {
const ei = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
const invite = guildInvites.find(i => ei.get(i.code).uses < i.uses);
const inviter = client.users.get(invite.inviter.id);
if(!inviter) inviter = `I can\'t figure out how ${member.displayName} joined the server.`;
i dont know how can i solve it, this is not all code i just send a part of my code but this where the error in
and pls can someone tell me how can i handle Promise bc i think this is the problem for example this is a code how can i handle it
client.on("message", async message=>{
if (message.isMentioned(client.user)){
let msg = await message.channel.send("xxx")
msg.edit(`xxx`)
}
});