我正在尝试在我的不和谐机器人中实现 js 代码。因此,我在网上获取了一些代码来尝试它是否正常工作,现在,我正在尝试像这样使用 queryselector:
if (msg.content === "!GuessNumber"){
let randomNumber = Math.floor(Math.random() * 100) + 1;
const guesses = document.querySelector('.guesses');
const lastResult = document.querySelector('.lastResult');
const lowOrHi = document.querySelector('.lowOrHi');
const guessSubmit = document.querySelector('.guessSubmit');
const guessField = document.querySelector('.guessField');
let guessCount = 1;
let resetButton;
但我有这个错误
ReferenceError: document is not defined
at Client.<anonymous> (/Users/zep/Documents/GitHub/Bot-discord/my-bot/index.js:18:23)
at Client.emit (events.js:311:20)
at MessageCreateAction.handle (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
at WebSocketShard.onMessage (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
at Receiver.receiverOnMessage (/Users/zep/Documents/GitHub/Bot-discord/my-bot/node_modules/ws/lib/websocket.js:801:20)
[nodemon] app crashed - waiting for file changes before starting...
有人可以帮我调试一下并使用https://github.com/mdn/learning-area/blob/master/javascript/introduction-to-js-1/first-splash/number-guessing-game 中的代码。我的机器人的html ?我来试试它是如何工作的,谢谢