小编Fla*_*nko的帖子

错误:字符串格式无效 | const 命令 = require(`${file}`);

我已经尝试了很多方法但仍然没有成功...

这是错误:

Error: Invalid string format
    at Object.run (/home/runner/discordgame-1/node_modules/@sapphire/shapeshift/dist/index.js:1281:64)
    at /home/runner/discordgame-1/node_modules/@sapphire/shapeshift/dist/index.js:113:66
    at Array.reduce (<anonymous>)
    at StringValidator.parse (/home/runner/discordgame-1/node_modules/@sapphire/shapeshift/dist/index.js:113:29)
    at validateName (/home/runner/discordgame-1/node_modules/@discordjs/builders/dist/index.js:885:17)
    at MixedClass.setName (/home/runner/discordgame-1/node_modules/@discordjs/builders/dist/index.js:957:5)
    at Object.<anonymous> (/home/runner/discordgame-1/commands/ping.js:5:6)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
Run Code Online (Sandbox Code Playgroud)

代码:

for (const file of commandFiles) {
    const command = require(`${file}`);
    commands.push(command.data.toJSON());
  client.commands.set(command.data.name, command);
}
Run Code Online (Sandbox Code Playgroud)

${file}const command = require( );肯定有问题。

我第一次使用stackoverflow,因为我真的找不到解决方案。

如果您想了解有关此问题的更多信息,请询问我。

discord.js

2
推荐指数
1
解决办法
1704
查看次数

标签 统计

discord.js ×1