mackex5x5
mackex5x5

Reputation: 11

Sending message to specific person

I want to get the bot messaging me what the user reported by !report @user#1234 Reason

message.author.send(${user} **Reported** ${userf} **for** ${reportReason}) ^

ReferenceError: user is not defined

if(message.content.startsWith(prefix + "report")){
    let author = message.member;
    let sentuser = author.user.tag;
    const userf = message.mentions.users.first(); 
    const reportReason = args.slice(1).join(' ');

    const userID = '123456789'; //My id

    async function declaredAsAsync() {
      const user = client.users.get(userID) || await client.fetchUser(userID);}



 message.author.send(`${user} **Reported** ${userf} **for** ${reportReason} `) 

}

I want it to work the right way without errors :>`

Upvotes: 0

Views: 86

Answers (1)

Natsathorn
Natsathorn

Reputation: 1528

You're using user outside of the scope that you defined it. In this case, you define it inside declaredAsAsync(), but you try to access it outside of that function.

To resolve the error, you can move this line to inside the function:

message.author.send(`${user} **Reported** ${userf} **for** ${reportReason}`)

Upvotes: 2

Related Questions