【发布时间】:2021-05-29 21:06:36
【问题描述】:
我正在制作一个不和谐的机器人并关注 Worn Off Keys 的视频。在第二集中,我遇到了一个错误。我什至复制并粘贴了他 github 上的代码,但它仍然不起作用。以下是我拥有的东西:
我的代码:
const Discord = require('discord.js')
const client = new Discord.Client()
const config = require('./config.json')
const command = require('./command')
client.on('ready', () => {
console.log(`${client.user.username} is up and running.`)
command(client, ['ping', 'test'], (message) => {
message.channel.send('shut up idc')
})
})
client.login(config.token)
这是我得到的错误:
Error: Cannot find module './command'
Require stack:
- /home/runner/discord-bot-2/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at /home/runner/discord-bot-2/index.js:5:17
at Script.runInContext (vm.js:130:18)
at Object.<anonymous> (/run_dir/interp.js:209:20)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
【问题讨论】:
标签: javascript node.js discord.js modulenotfounderror