-1
我目前正在爲一個不和諧BOT discord.js,但我發現了同樣的問題,所有的時間:公會沒有定義
ReferenceError: guild is not defined
at Client.client.on.message (C:\Users\Valentin\Documents\JsBot_dev\bot.js:27:30)
at emitOne (events.js:101:20)
at Client.emit (events.js:188:7)
at MessageCreateHandler.handle (C:\Users\Valentin\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Valentin\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:120:65)
at WebSocketManager.eventMessage (C:\Users\Valentin\node_modules\discord.js\src\client\websocket\WebSocketManager.js:273:31)
at WebSocket.onMessage (C:\Users\Valentin\node_modules\ws\lib\WebSocket.js:442:14)
at emitTwo (events.js:106:13)
at WebSocket.emit (events.js:191:7)
at Receiver.ontext (C:\Users\Valentin\node_modules\ws\lib\WebSocket.js:841:10)
我試圖更新我的discord.js和重新安裝節點.js但沒有任何工作。
感謝您的幫助!
殭屍代碼:
const Discord = require("discord.js");
const client = new Discord.Client();
myid = "your id is :"
const hook = new Discord.WebhookClient('NoIdForYou', 'NoTokenForYou');
client.on('ready',() => {
console.log(`Logged in as ${client.user.username}!`);
});
client.on('message', message => {
if (message.content === '-avatar') {
message.reply(message.author.avatarURL);
}
});
client.on('hook', hook => {
if (message.content === '-test') {
hook.sendMessage('Ok.')
}
});
client.on('message', message => {
if (message.content === '-react') {
const emoji = guild.emojis.first();
client.react(emoji.name.ballot_box_with_check)
}
});
client.login('NoTokenForYou');
你能顯示你的代碼嗎? – Li357
你要麼不顯示你所有的代碼,要麼你不是實例化的公會變量。 – Jackowski