top-gg / issues

Report bugs related to Top.gg. For feature requests: https://feedback.top.gg
35 stars 13 forks source link

top.gg api issue #806

Open ronbr2151 opened 3 years ago

ronbr2151 commented 3 years ago

Expected Behavior

I expected for my bot to post his stats

Observed Behavior

it shows an error

Applicable Links or Attachments

Image of the error

Steps to Reproduce

the code:

const dbltoken = 'my top.gg bots token'
const api = new Topgg.Api('my top.gg bots token')
const DBL = require("top.gg");
const dbl = new DBL(dbltoken, { webhookPort: port, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook's running`);
});
dbl.webhook.on('vote', vote => {

    bot.users.fetch(vote.user).then( u => {

        const votetestchannel = bot.channels.cache.find(channel => channel.id === "885139561355804703")

  console.log(`User with ID ${vote.user} just voted!`);
  votetestchannel.send("+1")
}).catch(console.error)
});

bot.on('ready', async () =>{
  console.log("this bot is online!");
  setInterval(() => {
      bot.user.setActivity(`with money | e!help | in ${bot.guilds.cache.size} servers.`, ({type: "PLAYING"}))
}, 600);
setInterval(() => {
  api.getStats('828349677950074881')
    console.log('posted guilds in top.gg')
}, 1000);  
})

Web Browser and Version

google is my web browser idk the version

Operating System and Version

Windows, idk the verstion

Screen Resolution

idk and i dont think its important in that case

Additional Information/Comments

it says i dont have a token but i do, and a mod told me to submit an issue here.

ExtremeDevelopments commented 3 years ago

Maybe because you put your token as my top.gg bots token here?

ronbr2151 commented 3 years ago

Maybe because you put your token as my top.gg bots token here?

no i did not

ExtremeDevelopments commented 3 years ago

Where is the error coming from? What api call?

Xetera commented 3 years ago

Can't help with library related errors. Try doing a raw http request and if it still fails with the correct headers and url then I can take a look

Wolletje01 commented 3 years ago

Broken tooth and I work sortoff together (I work on the website) and I have a simple API get request and it says unauthorized.

const fetch = require("node-fetch")
console.log(tokens.topggAuthorization)
const schhool = await fetch('https://top.gg/api/bots/828349677950074881/', {
    method: 'GET', headers: {
        "Authorization": tokens.topggAuthorization,
        "Content-Type": "application/json" //I also tried without the content type
    }
});
var topgg = await schhool
console.log(topgg)

With the response as:


Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kTransformState)]: [Object]
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://top.gg/api/bots/828349677950074881',
    status: 401,
    statusText: 'Unauthorized',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 1
  }
}
Wolletje01 commented 3 years ago

And yes we using the same topgg authorization token

Wolletje01 commented 3 years ago

Anyone knows the problem?