javascript - 找不到模块
问题描述
尝试发出一些经济命令,目前正在尝试发出将消息作者拥有的硬币总量发送给消息作者的命令。我继续收到“找不到模块”错误。我已尝试搜索此错误,但我似乎无法找到解决方案。
我的文件结构 - https://i.stack.imgur.com/sER3g.png
const { RichEmbed } = require("discord.js");
let coins = require("../coins.json");
module.exports = {
name: "coins",
descriptions: "shows how many coins you have",
category: "Economy",
run: async (client, message, args) => {
//coins
if(!coins[message.author.id]){
coins[message.author.id] = {
coins: 0
};
}
let uCoins = coins[message.author.id].coins;
let coinEmbed = new RichEmbed()
.setAuthor(message.author.username)
.setcolor("RANDOM")
.addField("", uCoins);
message.author.send(coinEmbed);
}
}
解决方案
根据您链接的文件结构,您require
正在寻找文件夹coins.json
中的commands
,因为您只在文件名前加上../
一次。为了获取您的文件,请在名称前加上../../
,因此它会上升两个文件夹。您的行将如下所示:
let coins = require("../../coins.json");
推荐阅读
- r - R中多组数据的正态性检验
- shell - 查找数字中的位数
- python-3.x - 用于识别 cisco 设备上的接口分类的 Python 模块
- javascript - 使用javascript更改滚动边距顶部
- python - tzinfo 参数必须是 None 或 tzinfo 子类,而不是类型 'datetime.datetime'
- elasticsearch - elasticsearch 证书位于何处
- azure-data-factory - 程序员使用 Azure 数据工厂进行简单的数据摄取
- docker - 通过 docker 使用虚拟摄像头进行视频通话客户端
- math - 如何找到数字序列,使其总和等于给定数字
- jenkins - 如何为属性的管道作业创建 dsl 脚本 - 在构建其他项目后构建