本文介紹了SyntaxError:意外的令牌'?在 repl.it 上用 JavaScript 制作不和諧機器人時的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我收到一個錯誤:
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
Discord Bot 代碼:
Code For Discord Bot:
const Discord = require("discord.js")
const client = new Discord.Client()
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on("message", msg => {
if (msg.content === "ping") {
msg.reply("pong")
}
})
client.login("my token here")
推薦答案
這大概和FreeCodeCamp教程有關使用 JavaScript 編寫 Discord 機器人.您實際上可以使用 repl.it shell 來解決這個問題.轉到 shell(控制臺選項卡右側的選項卡)并輸入 npm i discord.js@12.5.3
This is probably related to the FreeCodeCamp tutorial Code a Discord Bot with JavaScript. You can actually use the repl.it shell to solve this. Go to the shell (the tab on the right of the console tab) and enter npm i discord.js@12.5.3
這篇關于SyntaxError:意外的令牌'?在 repl.it 上用 JavaScript 制作不和諧機器人時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!