当我尝试执行我的脚本时,replit 上的控制台不起作用

When I try to execute my script the console on replit just doesnt work

我是 Javascript 的新手,所以请多多包涵!当我尝试执行我的脚本时,它没有响应!它只是一直掉到下一行,等待我再次写入节点 index.js。我在 Imgur 相册中发布了 2 张图片,第一张是我写节点 index.js,第二张是我按回车键和响应。字面意思是空白。 我需要一些帮助,因为我觉得这是启动我的机器人的最后一步 运行! :D。 https://imgur.com/a/bRFFKKf

这是我的index.js

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const {token} = require('./token.json');
var jsonconfig = require("./config.json")
var jsonconfig,DISCORD_ID
var CMDS = jsonconfig.CMDS

var prefix = 'p!'
client.on("message", message => {
var args = message.content.split(" ")
args.forEach((a, b) => {
  args[b] = a.replace("`", "")

  args[b] = args[b].replace(".", "")

  args[b] = args[b].replace("`", "")
  args[b] = args[b].replace(`"`, "")

  args[b] = args[b].replace(`'`, "")

})
var args = message.content.split(" ")
if (message.author.bot == false) {
  if (message.content.startsWith("$")) {

    if (message.channel.id != CMDS && message.author.id != DISCORD_ID) {
      message.reply("stop using cmds here idiot. <#" + CMDS + ">")
      return;
    }
  }

  args.forEach((a, b) => {
    args[b] = a.replace("`", "")
    
    args[b] = args[b].replace(".", "")

    args[b] = args[b].replace("`", "")
    args[b] = args[b].replace(`"`, "")

    args[b] = args[b].replace(`'`, "")

        })
  switch (args[0]) {
    
    case prefix + "pois":

  var id = parseInt(args[1])
  if (id) {
    fetch(`https://www.rolimons.com/uaid/` + id).then(res => res.text()).then(res => {
      //// clog(res)
      if (res != 'Uaid not found, try again later') {
        var search = res,
          first = 'uaid_details'
        var second = `owner_list`;
        var itemdat = JSON.parse(search.substring(search.indexOf(first) + first.length, search.indexOf(second)).replace(";", "").replace("=", "").replace("var", ''))
        // clog(itemdat)
        var search = res,
          first = 'item_details'
        var second = `uaid_details`;
        var itemname = JSON.parse(search.substring(search.indexOf(first) + first.length, search.indexOf(second)).replace(";", "").replace("=", "").replace("var", ''))
        var search = res,
          first = 'owner_list'
        var second = `lucky_cat_uaid`;
        var owners = JSON.parse(search.substring(search.indexOf(first) + first.length, search.indexOf(second)).replace(";", "").replace("=", "").replace("var", ''))
        message.reply(`Checking be patient bozo...`)
        var em = new discord.messageEmbed()
        .setFooter("Archs")
      .setURL("https://www.rolimons.com/item/" + args[1])
        .setColor("#ffc0cb")
        .setThumbnail("https://www.roblox.com/thumbs/asset.ashx?width=420&height=420&assetid=" + itemdat["asset_id"])
        .setTitle(`UAID ` + args[1])
        .setURL(`https://www.rolimons.com/uaid/` + args[1])
        .setAuthor(itemname.name, `https://www.roblox.com/thumbs/asset.ashx?width=420&height=420&assetid=` + itemdat["asset_id"])
      if (itemdat.serial) {
        em.addField('SERIAL', itemdat.serial)
          }
        em.addField('OWNER', (itemdat.owner_name || `Hidden/Deleted`))
        em.addField(`Last Traded`, itemdat["updated_relative_string"])
        message.reply(em)
        if (itemdat["updated_relative_string"].search(`month`) != -1 || itemdat["updated_relative_string"].search(`year`) != -1) {
          message.channel.send(`Since the current owner has had it for more than a month, we have deemed this uaid(${args[1]}) as CLEAN :white_check_mark:`)
          } else {
          comped_detected = false
          Object.keys(owners).forEach(x => {
            var item = owners[x][0]
            if (item && parseInt(x) + 2628000 >= Date.now() / 1000) {
              fetch(`https://avatar.roblox.com/v1/users/${item}/avatar`).then(res => res.json().catch(err => { })).then(avatar => {
                avatar.assets.forEach(a => {
                  if (badassets[a.id] != undefined) {
                    comped_detected = true
                                                            }
                })
                fetch("https://inventory.roblox.com/v1/users/" + item + "/assets/collectibles?sortOrder=Asc&limit=100").then(res => res.json().catch(err => { })).then(p => {
                  // clog(p)
                  var amt = 0
                  if (p.data) {
                    p.data.forEach(l => {
                      amt = amt + itemdata[l.assetId][4]
                      })
                    if (amt < 5000) {
                      comped_detected = true
                    }
                  }
                })
              })
            }
          })
        }
      }
    }
  )}
  }
}

client
    .login(token)
    .catch(consola.error)
  });

再次抱歉,如果这听起来很愚蠢,我刚刚开始 Javascript(节点)。还有件事儿!我正在尝试使用 discord 命令使其在 discord 上工作。感谢您的帮助。

您的代码似乎是以下形式:

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const {token} = require('./token.json');
var jsonconfig = require("./config.json")
var jsonconfig,DISCORD_ID
var CMDS = jsonconfig.CMDS

var prefix = 'p!'
client.on("message", message => {
 // stuff
})

所以基本上它似乎附加了某种监听器,然后到达终点。所以它什么都不做...

首先,如果您使用的是意图,我假设您使用的是 discord.js v13。在那种情况下 client.on("message" 将是 client.on("messageCreate".

您不需要在 repl.it 中输入节点 index.js。相反,转到文件上的 3 个点,如下所示,然后单击“显示隐藏文件”。一旦你看到 .replit 文件,进入它并在第一行写上:run = "npm start"。然后,进入 package.json(不是 package-lock.json)并在另一个屏幕截图上写下代码(我突出显示了代码以便您更容易阅读)。那应该可以解决您所有的问题!如果您需要更多参考,我已经粘贴了一些非常有用的 YouTube 教程,我绝对推荐您观看。

Tutorial - Command handler and help command

Tutorial - How to use Discord.js v13 in repl.it