So with my code it keeps showing an error and I have tried everything to solve it but nothing prevails.

Error

/home/runner/Funko-Bot/index.js:26
Client.login(process.env.T0KEN)
                               

SyntaxError: Unexpected end of input

Code

const Discord = require("discord.js")
const fetch = require("node-fetch")
const client = new Discord.Client()

function Funkounter() {
  return fetch("https://github.com/kennymkchan/funko-pop-data.git/random")
  .then(res => {
    return res.json()
  })
  .then(data => {
    return [0] ["q"] + " -" + data[0] ["a"]
  })

client.on("ready", () => { 
  console.log(`logged in as  $ 
  {client.user.tag}!`)
})

client.on("message", msg => {
  if (msg.author.bot) return
  if (msg.content === "fb!spawn"){
   Funkounter().then(quote => msg.channel.send(quote))
  }
}) 

client.login(process.env.T0KEN)

An unexpected end of input means (usually) the Javascript engine hit the end of your codeā€¦ And the the code came to a bad end. Usually something was opened, and not closed.

Count how many opening curly braces you haveā€¦ And how many closing curly braces you have.

The previous response likely is the cause for your error, but also wondering if:

Should be:

return data[0][ā€œqā€]

?

^ I would think so.

As said, check your bracketsā€¦did you forget to close something? I would suggest you throw your code into an editor like VS Code. It should give you a hint by marking part of the code as unreachable (dimmed out).

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.