Issue #3460Opened May 17, 2021by Redix00 reactions

BUG: TypeError: Cannot read property 'get' of undefined

Question

Error:

Code SnippetTEXT
(node:206) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
(node:206) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:206) [DEP0018] 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.

\\\\\\\\\\\\\\

Code :
 client.on("guildMemberAdd", async member => {
    const cachedInvites = guildInvites.cache.get(member.guild.id);
    const newInvites = await member.guild.fetchInvites();
    guildInvites.set(member.guild.id, newInvites);

    try{
        const usedInvite = newInvites.cache.find(inv => cachedInvites.cache.get(inv.code).uses < inv.uses);
        const joinChannel = member.guild.channels.cache.get(channel => channel.id === "840700441712263168")
        if(joinChannel) {
            joinChannel.send(`**><:Discord:831221457555554366>**Welcome ${member}  to our server Fiery Foxes E-Sports.** 
 

><:emoji_101:831317753204965407>**We hope you enjoy your time with us.**


><:emoji_100:831317050550779914>**Please don't forget to read**  #guidelines

><:fiery:830542549843443713>**Invited by : ${usedInvite.inviter} **

><:_hf_:826503267479322727>**Member count : ${member.guild.memberCount}**`)
            joinChannel.send("https://media.discordapp.net/attachments/806649507067723777/843579501413269564/10_3EA7AB3.gif").catch(err => console.log(err))

        }
    }
    catch(err) {console.log(err);}
})

Answers (1)

artfMay 22, 20210 reactions

Please follow the issue template

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.