我正在尝试myArr从hello.js导入index.js。但是我得到一个错误
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
Run Code Online (Sandbox Code Playgroud)
你好.js
export let myArr = ['hello', 'hi', 'hey'];
Run Code Online (Sandbox Code Playgroud)
索引.js
import { myArr } from './hello.js';
console.log(myArr);
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
我正在为我的送餐机器人发出订单命令。在主服务器外使用该命令时控制台出错,否则该命令在主通道内工作。
错误是 TypeError: Cannot read property 'id' of undefined代码是
api.commands.add("claim", (msg) => {
let employeeRole = msg.guild.roles.get("745410836901789749");
if(msg.member.roles.has(employeeRole.id)) {
if(msg.channel.id == 746423099871985755) {
api.client.channels.get("746423099871985755").fetchMessages({
around: order.ticketChannelMessageID,
limit: 1
}).then(messages => {
const fetchedMsg = messages.first();
fetchedMsg.edit({embed: {
color: 0xFFFFFF,
title: api.client.users.get(order.userID).username,
fields: [{
name: "Order Description",
value: order,
}, {
name: "Order ID",
value: ticketID,
}, {
name: "Order Status",
value: "claimed",
}],
timestamp: new Date(),
footer: {
text: "Taco Bot"
}
}}).then((m) => {
m = m.id;
// …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个使用discord.js 的tauri 应用程序(react+ts+vite)。但是,当我尝试运行该应用程序时,出现以下错误:
node_modules/discord-api-types/payloads/v9/permissions.js:17:16: ERROR: Big integer literals are not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")
Run Code Online (Sandbox Code Playgroud)
是否可以一起使用 tauri 和 Discord.js,或者我是否必须编写单独的应用程序和“discord bot”?
我知道询问有关错误本身的问题会更明智,但是浏览了一下互联网后,我没有找到任何东西,或者除了将compilerOptions设置为es2020之外,但这对我没有帮助。我还在 github 上发现了一个讨论浏览器中的discord.js 的问题,但它已经过时了。
为自我回答而编辑
message.guild.roles.find is not a function是在 DJS v12 上使用 DJS v11 方法的结果,换句话说message.guild.roles.find已经过时,应该替换为
message.guild.roles.cache.find
DJS v11 现已停产。按照本指南在这里更新 v12 的代码
我试图查找这个并没有找到答案。在箭头函数中传递 0 个参数时是否有任何理由使用_over ()?只是出于好奇而问。
// ...(() => {}) vs (_ => {})
Run Code Online (Sandbox Code Playgroud) discord.js ×3
javascript ×3
node.js ×2
ecmascript-6 ×1
export ×1
import ×1
parameters ×1
reactjs ×1
tauri ×1
typescript ×1