always reply to a specific user's messages

hello, i've only ever used djs for simple !ping pong! type commands, like !help for my discord members etc. I am wanting to set up a condition where if a specific user sends a message, any message, the bot will reply with !hi for example. i've tried using msg.author and msg.client but i may just be formatting it wrong as well. my bot.js is set up using if / else if as i only have a couple things in there. may i have some assistance if possible please? also i am on version 13.8.1.
6 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
mars
marsOP3y ago
likely! i'll give it a go and check back ty
if (message.author.id == "1023039537968074774") {
^
ReferenceError: message is not defined
at Client.<anonymous> (/home/container/bot.js:82:3)
at Client.emit (node:events:527:28)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:478:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:317:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:527:28)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1169:20)
Node.js v17.9.1
if (message.author.id == "1023039537968074774") {
^
ReferenceError: message is not defined
at Client.<anonymous> (/home/container/bot.js:82:3)
at Client.emit (node:events:527:28)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:478:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:317:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:527:28)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1169:20)
Node.js v17.9.1
got this error
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
mars
marsOP3y ago
sick sick, changing message to msg fixed it lol silly error tysm
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server