首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有人能帮我写这个不和谐虚荣狙击手机器人的代码?

有没有人能帮我写这个不和谐虚荣狙击手机器人的代码?
EN

Stack Overflow用户
提问于 2021-06-19 07:36:30
回答 1查看 241关注 0票数 0

下面的代码是这个不和谐虚荣狙击手机器人的代码,我几乎没有编码经验,我想在replit.com上运行它,它显示了一个错误,如果你能解决这个问题,我将非常感激,因为我是新手编码,我想在此之后开始学习如何制作一个不和谐机器人

错误:

代码语言:javascript
复制
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'
}

代码:

代码语言:javascript
复制
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"); 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-19 08:34:26

如果我重命名replit.com在启动新项目(repl)时创建的index.js文件,则可以重现此错误。确保您的代码位于名为index.js的文件中,因为这是应用程序的入口点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68042434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档