TypeError: Cannot read property 'get' of undefined (discord.js)

else if (authorApplication.step == 18) {

            authorApplication.answer18 = message.content;

            message.author.send(">>> Thank You!")

            message.channel.cache.get("774833147321647104")

            .send(`${message.author}\n >>> **Question 1: You  understand and AGREE that these positions are NON PAID positions for the time being. AND YOU MUST HAVE A MICROPHONE**  \n Answer: ${authorApplication.answer1}\n **Question 2: How Old are You?**  \n Answer: ${authorApplication.answer2}\n **Question 3: WE ASSIGN TASK IN A PROGRAM CALLED MEISTERTASK, PLEASE ATTACH YOUR EMAIL SO WE MAY ADD YOU TO THIS IF YOU ARE ACCEPTED. YOUR APPLCIATION AND PERSONAL INFO WILL BE DELETED IF YOU ARE DENIED** \n Answer: ${authorApplication.answer3}\n **Question 4: Please confirm that you are aware that only successful applicants will receive a response, and if no response is received you may reapply in 30 days?**\n Answer: ${authorApplication.answer4}\n **Question 5: What’s your minecraft Username?** \n Answer: ${authorApplication.answer5}\n **Question 6: What is your Discord Name?** \n Answer: ${authorApplication.answer6}\n **Question 7: What Position Are You Applying For? Helper, Mod, Builder Or Developer** \n Answer: ${authorApplication.answer7}\n **Question 8: Why Should We Choose You Over Others?** \n Answer: ${authorApplication.answer8}\n **Question 9: How much time do you have to contribute to the role?** \n Answer: ${authorApplication.answer9}\n **Question 10: Have you ever been banned or punished on any server? If so, please include details.** \n Answer: ${authorApplication.answer10}\n **Question 11: Do you have any experience with config or plugins, would you be able to edit configs if you are tasked with that job for the day?"**  \n Answer: ${authorApplication.answer11}\n **Question 12: Do you have any past staff experience?** \n Answer: ${authorApplication.answer12}\n **Question 13: What are your strengths and weaknesses** \n Answer: ${authorApplication.answer13}\n **Question 14: Why do you want to join AnytimeMC?** \n Answer: ${authorApplication.answer14}\n **Question 15: What can you bring to Our team?** \n Answer: ${authorApplication.answer15}\n **Question 16: IS THERE ANYTHING ELSE WE SHOULD KNOW?** \n Answer: ${authorApplication.answer16}\n **Question 17: YOU AGREE TO DO A VERBAL INTERVIEW IF YOUR APPLICATION IS ACCEPTED** \n Answer: ${authorApplication.answer17}\n **Question 18: IF YOU ARE APPLYING FOR BUILDER OR DEV, PLEASE SHOW ANY PORTFOLIOS IN THE VERBAL INTERVIEW.** \n Answer: ${authorApplication.answer18} `);

            delete userApplications[authorId];

                          

            }

Here is the code! Its a application bot and this is the only part that isnt working

Could ya format your code so I can understand it better? :slight_smile:

if (authorApplication.step == 18) {
authorApplication.answer18 = message.content;
message.author.send(">>> Thank You!");
message.channel.cache
.get(“774833147321647104”)
.send(
${message.author}\n >>> **Question 1: You understand and AGREE that these positions are NON PAID positions for the time being. AND YOU MUST HAVE A MICROPHONE** \n Answer: ${authorApplication.answer1}\n **Question 2: How Old are You?** \n Answer: ${authorApplication.answer2}\n **Question 3: WE ASSIGN TASK IN A PROGRAM CALLED MEISTERTASK, PLEASE ATTACH YOUR EMAIL SO WE MAY ADD YOU TO THIS IF YOU ARE ACCEPTED. YOUR APPLCIATION AND PERSONAL INFO WILL BE DELETED IF YOU ARE DENIED** \n Answer: ${authorApplication.answer3}\n **Question 4: Please confirm that you are aware that only successful applicants will receive a response, and if no response is received you may reapply in 30 days?**\n Answer: ${authorApplication.answer4}\n **Question 5: What’s your minecraft Username?** \n Answer: ${authorApplication.answer5}\n **Question 6: What is your Discord Name?** \n Answer: ${authorApplication.answer6}\n **Question 7: What Position Are You Applying For? Helper, Mod, Builder Or Developer** \n Answer: ${authorApplication.answer7}\n **Question 8: Why Should We Choose You Over Others?** \n Answer: ${authorApplication.answer8}\n **Question 9: How much time do you have to contribute to the role?** \n Answer: ${authorApplication.answer9}\n **Question 10: Have you ever been banned or punished on any server? If so, please include details.** \n Answer: ${authorApplication.answer10}\n **Question 11: Do you have any experience with config or plugins, would you be able to edit configs if you are tasked with that job for the day?"** \n Answer: ${authorApplication.answer11}\n **Question 12: Do you have any past staff experience?** \n Answer: ${authorApplication.answer12}\n **Question 13: What are your strengths and weaknesses** \n Answer: ${authorApplication.answer13}\n **Question 14: Why do you want to join AnytimeMC?** \n Answer: ${authorApplication.answer14}\n **Question 15: What can you bring to Our team?** \n Answer: ${authorApplication.answer15}\n **Question 16: IS THERE ANYTHING ELSE WE SHOULD KNOW?** \n Answer: ${authorApplication.answer16}\n **Question 17: YOU AGREE TO DO A VERBAL INTERVIEW IF YOUR APPLICATION IS ACCEPTED** \n Answer: ${authorApplication.answer17}\n **Question 18: IF YOU ARE APPLYING FOR BUILDER OR DEV, PLEASE SHOW ANY PORTFOLIOS IN THE VERBAL INTERVIEW.** \n Answer: ${authorApplication.answer18}
);
delete userApplications[authorId];

Whoops. Do you have a database to send their data, which when you get it it is undefined? You could try a JSON database to store it and fetch it.

I recommend using npmjs.com/package/jsonfile compared to those junky others.

it used to work. i need the code to stay like this but idk why get is undefiened

I am assuming it’s something outside the IF.

what do you mean?

The if statement

no. everything else works its just when it gets to then the error happens

Ah. Can you show the rest of the node.js code?

and put three backticks between the beginning and end of your code in here?

Also, don’t share your token, because their could be dragons :dragon:

https://pastebin.com/6ZWZv1ax here is a pastebin

any help or?

I think you need to replace message.channel.cache.get with client.channels.cache.get.

now i get this

ReferenceError: Client is not defined

how can i fix this? it was working a few days ago now its not

Maybe you are using client, bot or Bot instead of Client

if (authorApplication.step == 18) {
    authorApplication.answer18 = message.content;
    message.author.send(">>> Thank You!");
    message.channel.cache
        .get(“774833147321647104”)
        .send(
            $ {
                message.author
            }\
            n >>> ** Question 1: You understand and AGREE that these positions are NON PAID positions
            for the time being.AND YOU MUST HAVE A MICROPHONE ** \n Answer: $ {
                authorApplication.answer1
            }\
            n ** Question 2: How Old are You ? ** \n Answer : $ {
                authorApplication.answer2
            }\
            n ** Question 3: WE ASSIGN TASK IN A PROGRAM CALLED MEISTERTASK, PLEASE ATTACH YOUR EMAIL SO WE MAY ADD YOU TO THIS IF YOU ARE ACCEPTED.YOUR APPLCIATION AND PERSONAL INFO WILL BE DELETED IF YOU ARE DENIED ** \n Answer: $ {
                authorApplication.answer3
            }\
            n ** Question 4: Please confirm that you are aware that only successful applicants will receive a response, and
            if no response is received you may reapply in 30 days ? ** \n Answer : $ {
                authorApplication.answer4
            }\
            n ** Question 5: What’ s your minecraft Username ? ** \n Answer : $ {
                authorApplication.answer5
            }\
            n ** Question 6: What is your Discord Name ? ** \n Answer : $ {
                authorApplication.answer6
            }\
            n ** Question 7: What Position Are You Applying For ? Helper, Mod, Builder Or Developer ** \n Answer : $ {
                authorApplication.answer7
            }\
            n ** Question 8: Why Should We Choose You Over Others ? ** \n Answer : $ {
                authorApplication.answer8
            }\
            n ** Question 9: How much time do you have to contribute to the role ? ** \n Answer : $ {
                authorApplication.answer9
            }\
            n **
            Question 10: Have you ever been banned or punished on any server ? If so, please include details. ** \n Answer : $ {
                authorApplication.answer10
            }\
            n ** Question 11: Do you have any experience with config or plugins, would you be able to edit configs
            if you are tasked with that job
            for the day ? "** \n Answer: ${authorApplication.answer11}\n **Question 12: Do you have any past staff experience?** \n Answer: ${authorApplication.answer12}\n **Question 13: What are your strengths and weaknesses** \n Answer: ${authorApplication.answer13}\n **Question 14: Why do you want to join AnytimeMC?** \n Answer: ${authorApplication.answer14}\n **Question 15: What can you bring to Our team?** \n Answer: ${authorApplication.answer15}\n **Question 16: IS THERE ANYTHING ELSE WE SHOULD KNOW?** \n Answer: ${authorApplication.answer16}\n **Question 17: YOU AGREE TO DO A VERBAL INTERVIEW IF YOUR APPLICATION IS ACCEPTED** \n Answer: ${authorApplication.answer17}\n **Question 18: IF YOU ARE APPLYING FOR BUILDER OR DEV, PLEASE SHOW ANY PORTFOLIOS IN THE VERBAL INTERVIEW.** \n Answer: ${authorApplication.answer18}
        );

Is message.channel.cache defined? what does it return?

1 Like

TypeError: Cannot read property ‘get’ of undefined

No, message.channel.cache itself. Does it show an object? How about message.channel? Did you try looking up this error or looking at DJS docs? You might be using the wrong property.

You could be using a version of discord.js that doesn’t have a cache property.
In the latest docs for discord.js in both the channel and textchannel docs I don’t see a cache property