久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 REPLIT 創建我的第一個機器人,但總是錯誤

Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS)
本文介紹了使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我剛剛在 Replit 上啟動了 Discord.JS.它遵循 FreeCodeCamp 關于 https://www 的教程.freecodecamp.org/news/create-a-discord-bot-with-javascript-nodejs/

I have just started Discord.JS on Replit. It followed FreeCodeCamp's Tutorial on https://www.freecodecamp.org/news/create-a-discord-bot-with-javascript-nodejs/

但是當我運行代碼時它告訴我運行:

But when I runned the code it telled me to run :

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(process.env.TOKEN)

它告訴這個錯誤:

Error: Cannot find module 'node:events'
Require stack:
- /home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/Omega-Flowey-JS-Test/node_modules/discor
Error: Cannot find module 'node:events'
Require stack:
- /home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/index.js
- /home/runner/Omega-Flowey-JS-Test/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/client/BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19

誰能告訴我什么錯誤?我是 Discord.JS 的新手,所以我不知道有什么錯誤.

Can someone tell me whats error? I'm very new at Discord.JS so I don't know anything that is error.

推薦答案

Discord.js v13 需要 Node.js v16.6.Replit 僅直接支持 Node.js v12.16.1(在撰寫本文時).

Discord.js v13 requires Node.js v16.6. Replit only directly supports Node.js v12.16.1 (at the time of writing).

使用舊版本的 Node.js 時,您可能會看到諸如

When using an older version of Node.js, you may see errors such as

  • 錯誤:找不到模塊'node:events'
  • ReferenceError: AbortController 未定義
  • SyntaxError: Unexpected token '?'

但是,您可以使用 node npm 包安裝更新的 Node.js 二進制文件.

However, you can install a newer Node.js binary using the node npm package.

這是一個最小設置:

package.json

{
  "name": "node.js-v16-on-replit-demo",
  "version": "0.0.1",
  "dependencies": {
    "discord.js": "^13.2.0",
    "node": "^16.10.0"
  }
}

.replit

run = "npx node ."

index.js

const Discord = require("discord.js")

// your code...

你可以試試這個demo repl.

如果你喜歡,你可以定義一個 start npm 腳本:

If you like, you can define a start npm script:

package.json

{
  // ...
  "scripts": {
    "start": "node ."
  }
}

.replit

run = 'npm start'

還有 網上有大量關于 Node 的資源.js v16 在 Replit 上.

There are also plenty of resources online about Node.js v16 on Replit.

這篇關于使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應)
Check if user ID exists in Discord server(檢查 Discord 服務器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
DeprecationWarning: Collection#find: pass a function instead(DeprecationWarning: Collection#find: 傳遞一個函數)
主站蜘蛛池模板: 麻豆国产一区二区三区四区 | 日韩精品在线一区二区 | 精品久久久久久亚洲综合网 | 国产乱码精品一区二区三区av | 国产精品不卡 | 日韩av在线一区 | 国产成人精品免费视频 | 国产精彩视频 | 亚洲伦理自拍 | 91视频在线看 | 国产视频1 | 精品视频一区二区 | 91精品国产91久久久久久吃药 | 欧美一区精品 | 亚洲成人精品一区 | 久久久久国产一区二区三区 | 亚洲午夜在线 | 亚洲一区二区久久 | 91久久国产 | 久久久久久国产精品免费免费狐狸 | 日韩精品一区二区在线观看 | 国产一区二区精品在线观看 | 欧美精品久久久久久久久老牛影院 | 中文字幕不卡在线观看 | 欧美日韩视频在线第一区 | 亚洲一区二区高清 | 亚洲精品视 | 男人天堂视频在线观看 | 欧美激情精品久久久久久变态 | 欧美一级免费 | 在线亚洲免费 | jⅰzz亚洲 | 欧美日本韩国一区二区 | 色爱综合 | 久久久久久中文字幕 | 一区二区在线不卡 | 一级免费毛片 | 欧美 日韩 国产 成人 在线 | 91色视频在线观看 | 综合久久99 | 中文字幕国产精品 |