下面的代码是这个不和谐虚荣狙击手机器人的代码,我几乎没有编码经验,我想在replit.com上运行它,它显示了一个错误,如果你能解决这个问题,我将非常感激,因为我是新手编码,我想在此之后开始学习如何制作一个不和谐机器人
错误:
internal/fs/utils.js:269
throw err;
^
Error:
ENOENT: no such file or directory, open '/home/runner/RudePartialBuckets/index.js'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at Object.<anonymous> (/run_dir/interp.js:195:19)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/home/runner/RudePartialBuckets/index.js'
}代码:
const Discord = require('discord.js'),
client = new Discord.Client(),
moment = require("moment-timezone"),
fetch = require('node-fetch');
class Main {
constructor() {
this.sniperInterval;
}
async setVanityURL(url, guild) {
const time = moment.tz(Date.now(), "Europe/Paris").format("HH:mm:ss");
console.log(`[${time}] [LOG] Sniping discord.gg/${url}`);
return await fetch(`https://discord.com/api/v8/guilds/${guild.id}/vanity-url`, {
"credentials": "include",
"headers": {
"accept": "*/*",
"authorization": "Bot " + client.token,
"content-type": "application/json",
},
"referrerPolicy": "no-referrer-when-downgrade",
"body": JSON.stringify({
"code": url
}),
"method": "PATCH",
"mode": "cors"
});
}
async checkVanityURL(url) {
return await fetch(`https://discord.com/api/v8/guilds/${guild.id}/vanity-url`, {
"credentials": "include",
"headers": {
"accept": "*/*",
"authorization": "Bot " + client.token,
"content-type": "application/json",
},
"referrerPolicy": "no-referrer-when-downgrade",
"method": "GET",
"mode": "cors"
});
}
async startSnipe(url, guild) {
this.sniperInterval = setInterval(async () => {
await this.setVanityURL(url, guild);
}, 1000);
}
stopSnipe() {
return clearInterval(this.sniperInterval);
}
}
const prefix = ".";
let handler = new Main();
client.on('message', async (message) => {
let messageArray = message.content.split(" "),
args = messageArray.slice(1);
const args1 = message.content.slice(prefix.length).split(/ +/),
command = args1.shift().toLowerCase();
if (command === "start-snipe") {
let url = args[0];
if (!message.guild.features.includes('VANITY_URL')) {
return message.reply("You don't have level 3 boost !");
};
message.reply(`Start sniping the url ${url} now!`);
console.log(`[LOG] Start sniping the url ${url} now!`);
await handler.startSnipe(url, message.guild);
};
if (command === "stop-snipe") {
handler.stopSnipe();
};
});
client.login("YOUR BOT TOKEN"); 发布于 2021-06-19 08:34:26
如果我重命名replit.com在启动新项目(repl)时创建的index.js文件,则可以重现此错误。确保您的代码位于名为index.js的文件中,因为这是应用程序的入口点。
https://stackoverflow.com/questions/68042434
复制相似问题