我正在尝试制作一个Discord机器人,它只会显示是否有人在线玩游戏。
然而我不断收到这样的消息:
[ERR_REQUIRE_ESM]:不支持 ES 模块的 require()。相反,将index.js in... 的 require 更改为动态 import(),该动态 import() 在所有 CommonJS 模块中都可用。
这是我的代码:
module.exports = {
name: 'username',
description: "this is the username command",
async execute(message, args) {
const fetch = require('node-fetch');
if (args.length !== 1) {
return message.channel.send("invalid username wtf")
}
const ign = args[0]
if (ign.length > 16 || ign.length < 3) {
return message.channel.send("invalid username wtf")
}
const uuid = await fetch(`https://api.mojang.com/users/profiles/minecraft/${ign}`).then(data => data.json()).then(data => data.id).catch(err => message.channel.send("error wtf"));
const onlineInfo = …Run Code Online (Sandbox Code Playgroud)