Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unexpected string in JSON at position 41

I’m a newbie to Javascript, I do not quite know what this error means:

SyntaxError: /home/runner/myrepl/config.json:
Unexpected string in JSON at position 41

My index.js looks fine at position 41 (I think).
Here is my 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!'

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 + ">")
    }
  }

  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)

Here is my config.json if that helps:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
  "DISCORD_ID": "mydiscordIDishere"
  "CMDS": "mycommandschannelIDishere"
}

I have, discord.js, discord, npm and node.js installed. Please help I feel like I am really close to complete this project.

I am trying to make it work through discord by easy commands like p!pois uaid.
Though I have spent quite a while trying to fix problems like these and I don’t quite get how to solve it. I am running this on Replit.

>Solution :

Try to just add a comma on the 2nd line of config.json
Actually:

{
  "DISCORD_ID": "mydiscordIDishere"
  "CMDS": "mycommandschannelIDishere"
}

After:

{
  "DISCORD_ID": "mydiscordIDishere",
  "CMDS": "mycommandschannelIDishere"
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading