Code Monkey home page Code Monkey logo

blapi's People

Contributors

7coil avatar advaith1 avatar allcontributors[bot] avatar angeloanan avatar anishanne avatar codacy-badger avatar dependabot[bot] avatar donovandmc avatar jacobmitchell04 avatar jonahsnider avatar mattipv4 avatar maybeanerd avatar meerbiene avatar promise avatar renovate[bot] avatar secludedhusky avatar skye-31 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

blapi's Issues

Why don't the bot's users appear on discordbotlist.com?

Describe the bug
I see that if you update what is the number of servers that the bot has, but you don't see that it updates the number of users that the bot has, on the page it shows as "Unknown" and I do it manually if I can put it, but this package does not put that field for that page, and I imagine that also for other pages that I have not tried.

To Reproduce
Steps to reproduce the behavior:

  1. Set the handle.
  2. Wait for the bot statistics to update on the bot list pages.
  3. See how in discordbotlist.com the number of users that the bot has is not updated (I have not tried with the other pages).

Expected behavior
See the total number of servers with the bot and the total number of users with the bot on discordbotlist.com (or on other pages that I have not tried).

Screenshots
image

feat: add discord.js v13 support

we want to support both v12 and v13, when it launches
for now it seems the only typechange is:

  • shardID to shardId

if any more come up, we should add them to this issue

image

Add BLAPI to github packages

We would want to add an automatic release to GitHub packages into the existing CI.
It should already exist partly but does not work fully yet. Most likely, the access key is invalid, as we probably need one from @botblock/libs directly, and not myself.

The goal:
Make it deploy to both npm and GitHub packages at the same time.

Race condition when using 1+ shards

This affects the pr/14 branch.

When the handle() function is called, it uses the passed in client object to get the shard (if existent), and then calls fetchClientValues(). If all shards aren't ready, this throws an error and fails to post the information.

This happens because shards are started at a delay. If shard 0 doesn't call handle() when every shard is ready, this will error every time. The solution is to wait until all shards are ready before running the fetchClientValues code.

Normally, you might think 'Just use the event that runs when all the shards are ready.' That event doesn't exist, though. The only way to dynamically wait before calling the function is to write your own implementation of an allShardsReady event or some other way of waiting for every shard to get ready.

Another, a simpler solution would be to just wait 45 or so seconds before calling the function and hope your shards are ready then.

Add eris support on "handle"

feel free to open a PR for this issue! It's currently not being worked on

Discord.js isn't the only library developers use.
Eris has types and should, therefore, be somewhat easy to also be added.
We would want a clear distinction of both libs within BLAPI, depending on the differences.

BLAPI Not Posting w/Traditional Sharding

Describe the bug
BLAPI does not post through the handle function on start when using traditional sharding. It is unclear how one is meant to use BLAPI with traditional sharding. Am I meant to use manualPost, and if so, can an example be provided?

To Reproduce
Steps to reproduce the behavior:

  1. Create a bot which uses traditional sharding (using Discord.js ShardingManager in index.ts file)
// index.ts
const manager = new ShardingManager('./dist/bot.js', { token: process.env.DISCORD_TOKEN, totalShards: 3 });
  1. Put BLAPI in the bot.ts file (not the main index.ts file)
// bot.ts
import { Client } from 'discord.js';
import { handle, setLogging } from 'blapi';
const client = new Client();

await client.login(process.env.DISCORD_TOKEN);

const botListAPIKeys = {
  'voidbots.net': process.env.VOIDBOTS_KEY
};

setLogging({
  extended: true,
  logger: logger
});
await handle(client, botListAPIKeys);
  1. Run code
  2. Observe an error is outputted.
BLAPI: Error [ShardingInProcess]: Shards are still being spawned.

Expected behavior
BLAPI posts to bot lists without any issues.

rework the contributors crediting

currently all contributors are listed in the package.json as well as the file AUTHORS
package seems to not do anything, not even on npm, so if there's no reason to include everyone in there , i'd clean it up to only contain maintainers (in this case,me)

id like to rework the AUTHORS file so that instead of it, we use https://allcontributors.org/docs/en/bot/overview in the readme.

this makes it easier to find contributors as well as crediting them in general

typings: manualPost too many arguments

Describe the bug
The typings on BLAPI#manualPost is expecting 6 arguments but it really needs 3 (guildCount, botID and apiKeys) since some are optional.

Screenshots
Image

Improper jsdoc throws errors in typescript

Describe the bug
Improper jsdoc throws errors in typescript

To Reproduce
Steps to reproduce the behavior:
use blapi.manualPost with the 5th argument in typescript

// direct copied code
// this: Eris.Client extended by eris-sharder
let g = [];
for(let i = 0;i < this.bot.shards.size; i++) g.push(Object.values(this.bot.guildShardMap).filter(s => s === i).length);
blapi.manualPost(client.bot.guilds.size,client.bot.user.id,config.botLists,0,client.bot.shards.size,g);

// error at g: 
// Argument of type 'any[]' is not assignable to parameter of type '[any]'.
// Property '0' is missing in type 'any[]' but required in type '[any]'.ts(2345)

Expected behavior
No error should be thrown by typescript

Screenshots
TypeScript Error

Additional context
Works fine in normal javascript, but jsdoc is still messed up

Bug: BFD posting fails

Describe the bug
Looks like when blapi is posting through botblock it attempts to post to bfd (set in my code as botsfordiscord.com, a legacy id for discords.com), but when botblock is disabled, it does not log anything for bfd

Expected behavior
Should Post to bfd as well

Additional context
Could be related to legacy ID handling

Any example of how to do it with Sharding Manager?

In the documentation I do not see an example of how to do it with the Sharding Manager of Discord.js, I would like to know how to do it since I cannot put the handler method in the onReady of my Discord client because of the Shards that are being created, no they all have the same guild value.

Cannot read property 'size' of undefined in blapi.js

Describe the bug
This is probably somehow a bug in https://github.com/ddugovic/lishogi-discord , but I don't understand how to troubleshoot it. Upon attempting to retrieve the server count, my bot crashes.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/ddugovic/lishogi-discord & install dependencies
  2. Supply config.json with a valid Discord token
  3. /usr/bin/node /home/lichess/lichess-discord/index.js

Expected behavior
Bot does not crash

Screenshots

lichess@vps178028:~/lichess-discord$ /usr/bin/node /home/lichess/lichess-discord/index.js
[ERROR] BLAPI Discord client seems to not be connected yet, so we're skipping this run of the post. We will try again in 1 minutes.
Bot is online!
2 users, in 1 servers connected.
Uncaught Promise Error:  TypeError: Cannot read property 'size' of undefined
    at /home/lichess/lichess-discord/node_modules/blapi/dist/blapi.js:241:42
    at step (/home/lichess/lichess-discord/node_modules/blapi/dist/blapi.js:57:23)
    at Object.next (/home/lichess/lichess-discord/node_modules/blapi/dist/blapi.js:38:53)
    at /home/lichess/lichess-discord/node_modules/blapi/dist/blapi.js:32:71
    at new Promise (<anonymous>)
    at __awaiter (/home/lichess/lichess-discord/node_modules/blapi/dist/blapi.js:28:12)
    at handleInternal (/home/lichess/lichess-discord/node_modules/blapi/dist/blapi.js:203:12)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

Additional context
Bot is hosted on OVH. I just switched to using this library from using dblapi.js which produced a similar error.

Ban Support 🤔

Hey everyone I didn’t know how else to go about doing this so I figured maybe I should just make a issue. About a month or two ago (maybe longer) I was banned from the BotBlock server for “being toxic” after simply asking for support and having a member attack me but anyways that’s not what I’m here for

I was wondering if it’s possible for me to appeal this ban, I am deeply sorry for my actions that day I was just having a bad day in general and I realize now that maybe I should have just said nothing to the person who started the argument.

90% of our users for both Paradise and Infinity use the BotBlock API and honestly the best way I can see to offer them any support they may need with these lists is to be a member of the server.

My actions on the day of my ban were uncalled for and that I understand if given another chance I promise I will keep to myself unless directly asked for assistance ❤️

Edit: I just realized I posted this on the API Repo not the main Repo my bad 😬 sorry I just woke up like 20 mins ago lol

Thanks in Advance

  • Toxic Dev

Bring your own logger

Is your feature request related to a problem? Please describe.
Not related to a problem just an idea by @Huskydog9988

Describe the solution you'd like
Passing your own logger so you dont get console outputs for people that are using some special logger like bunyan or something. Would required their logger to at least have a loglevel for info, warn and errors.

Describe alternatives you've considered
I thought about overwriting the console.log method globally but that didn't feel right.

Concept

blapi.setLogger(myLogger)

EDIT:
Alternative Conept

blapi.setLogging({
extended: true,
logger: myLogger
})

Sharding support

Currently BLAPI doesn't have any code for sharding support. Will there ever be support to send shards along with their server counts to supported listings?

Using Sharding Does Not Post Any Stats..

Describe the bug
No stats have bene posted to any bot list when i started using sharding...

To Reproduce
Steps to reproduce the behavior:

  1. Get a sharded bot
  2. Use the blapi post though your API with 60 minute
  3. wait 1 hour and see nothink posted

Expected behavior
Should post all stats and shards, i tried without sharding and worked again.

Question
is there anything i have to do to use Sharding with it?

BLAPI NPM Package Not Working On Docker-Compose?

Describe the bug
I was running the bot on a standard PM2 server config all fine now we have switched to Docker-Compose and the BLAPI will show no errors at all and at the start shows its working just no bot lists have been updated?

To Reproduce
Make a bot using Docker-Compose and send the stats to a botlist using the AutoPost with it set to 60 minutes.

Expected behavior
should post.

Logging

Is your feature request related to a problem? Please describe.
Ability to log if the count has been successfully / failed to send to the list.

Describe the solution you'd like
Basically an option to log to log as stated above.

Describe alternatives you've considered
N/A

Additional context
N/A

Sharding is posting 1 shard server count

My bot is on thousands of servers and has 4 shards. BLAPI is sending to server listings that support shards and don't that it has 4 shards and is only on 912 servers (the first shard's server count).

I am running the latest version of BLAPI from GitHub and I'm not using manual posting.

Why is this happening and how can I fix this?

Add Support for discord.js v14

Is your feature request related to a problem? Please describe.
Discordjs v14 was released, and most likely it brings some changes to the client type.

Describe the solution you'd like
Support the type of v14 without the addition of a new required dependency. Maybe add it as optional peer dependency, if that makes it easier to manage

Feature: Read botlist tokens from env

It would be rather convenient if BLAPI could just get all tokens from the Environment.
An Idea would be to prefix them with BLAPI_ oder BOTLIST_TOKEN
An Open question is how to map them. An Idea:
Domain name (without ending or subdomain)
Would only work if there are no duplicates with other endings or subdomains, an example would be:
BLAPI_ondiscord for bots.ondiscord.xyz

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/npmpublish.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • centra 2.7.0
  • @types/centra 2.2.3
  • @types/node 20.14.15
  • @typescript-eslint/eslint-plugin 7.18.0
  • @typescript-eslint/parser 7.18.0
  • eslint-config-airbnb-base 15.0.0
  • prettier 3.3.3
  • rimraf 5.0.10
  • typescript 5.0.4
  • discord.js 13 - 14
nvm
.nvmrc
  • node 20.16.0

  • Check this box to trigger a request for Renovate to run again on this repository

Metalist rebranding

Metalist rebranded to BotBlock, the package should be updated as the URL for the API has changed.

Use @aero/centra or centra instead of node-fetch

Is your feature request related to a problem? Please describe.

I'm always frustrated when I want to install a package and it comes with node-fetch and therefore unneded clutter. Please use something more lightweight like centra or the aero fork of it.

Describe the solution you'd like

Use something more lightweight like centra or the aero fork of it. (https://www.npmjs.com/package/@aero/centra)

Describe alternatives you've considered

If you guys want i can make a pull request and implement it for you.

Add LBots.org

It'd be cool if LBots.org could be added, and supported, by this module

Add legacy IDs

Is your feature request related to a problem? Please describe.
If botlists rebrand and/or change names, when and how does the library adapt?

Describe the solution you'd like
Make the lib support new and older, legacy versions of botlist IDs

Describe alternatives you've considered
None

Additional context
Botblock will add this as well, so we only need to handle it on calls which don't use botblock.
Was created based on #39

Add tests

It would be nice to be able to quickly and safely release new versions e.g. with package/dependency updates.
Adding tests for the default use cases should help doing that with confidence.

Add VoidBots.net to BLAPI

Is your feature request related to a problem? Please describe.
VoidBots.net isn't listed on BLAPI and therefore should be added.

Describe the solution you'd like
Adding voidbots.net to BLAPI should be considered.

Additional context
You can find a link to their documentation here.

BLAPI Error: connect ETIMEDOUT

Describe the bug
I can't send my bot stats because I get an error.

To Reproduce
Steps to reproduce the behavior:

  1. Post new stats

Expected behavior
That the statistics are posted correctly.

Screenshots
image

Additional context

[ERROR] BLAPI Error: connect ETIMEDOUT 172.67.175.211:443

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.