S
S
SlyuJoke2021-05-12 20:20:16
Node.js
SlyuJoke, 2021-05-12 20:20:16

Discord Bot how to fix error?

The code:

client.on('message', msg => {
    if (msg.content === '!role') {
        let nickname1 = msg.author.nickname

        if(nickname1.startsWith(`[Discord]`)) {
            message.channel.send(`+тег`)
        } else {
            message.channel.send(`-тег`)
        }
    }
})


Mistake:
if(nickname1.startsWith(`[Discord]`)) {
                     
TypeError: Cannot read property 'startsWith' of undefined

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-05-12
@SlyuJoke

- let nickname1 = msg.author.nickname
+ let nickname1 = msg.member.nickname

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question