Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A simple to use poster for DiscordBotList stats, when you just want to post stats without much fussing around!
It's super easy to get started with dblposter! Let's guide you through the steps you need to do to be sending stats automatically in no time!
First, you have to install the module. So...
npm i dblposter
# Or if you are using yarn
yarn add dblposter
After that's done, all you have to do is:
const dbl = require("dblposter")
in your main client class above everything
new Client
(or whichever method is used by your chosen library), add the following code:// Assuming client is your variable name for the client,
// otherwise just change it as fit.
const poster = new dbl("DBL_API_KEY_GOES_HERE", client);
// This will bind the poster to your client and start posting automatically.
poster.bind();
Ok, if you've reached this point, you're probably curios about exactly what this library can do.
First, let's talk about the bind
function above. It takes two parameters:
Parameter Name | Type | Default | Description |
---|---|---|---|
paramName | String | dblPoster | The property which will get attached to the client in order to handle timers. |
client | DiscordJS.Client or Eris or DiscordIO.Client or DiscordIE.Client | this.client | The client to bind to, defaulting to the client provided in the constructor, if any. |
Say you don't want to have that property name because it is easy to guess. You could run bind("myParamName")
and dblposter would attach it using myParamName
If you didn't pass in a client in the new dbl
constructor, you can pass it in bind too! Just remember, if you don't want the paramName to be changed, you'll have to do something like bind(null, client)
.
While dblposter does add a property to the client, all the property has is your cached API Key, and the interval used to send the statistics. Nothing else is added, and no data is received from your client. I understand why some might be concerned, but here are the lines that handle the bind.
We send stats every 30 minutes, since that's what DiscordBots require for automatic libraries.
dblposter also has a post
method, which, as it's name suggests, does a post for you.
Note that this will reset the internal interval.
If you ever want to destroy dblposter (clear the internal interval, for shutdown or just to stop posting stats all together), there is the destroy
function. Run it and, voila. The interval gets stopped, dblposter removes itself from your client, nulls the paramName (meaning you'll have to re-add it in bind
should you call it after destroying)
Inside Reveal: We use the destroy function ourselves when you run the
post
function, but we save the paramName before hand.
And in the end, dblposter extends EventEmitter, and has 2 possible events:
Event Name | Event Params | Description |
---|---|---|
posted | The post was successfully done. Use this event if you want to log that the post was successful. | |
error | Snekfetch.Response | The post couldn't finish. The returned property from the event is a Snekfetch Response Object containing more informations. |
To access it, it's as easy as:
client.dblPoster.on("posted", () => {
console.log("Woop! My stats were posted");
});
client.dblPoster.on("error", err => {
// We recommend you check what the error was.
// Access the status, and body property from the err object.
console.log("Oh noes! I got an error!", err);
});
If you provided a different paramName in bind
, just replace dblPoster
from that snippet above with your param name.
When running bind
, if something isn't right, you will receive an error.
Message | Meaning |
---|---|
The API key is either not specified, or is not a string. | Where you constructed dblposter using new poster , you didn't provide an API Key or it wasn't a string. Double check and try again. |
You need to provide a client to bind to, either in the constructor of dblposter or in the bind function! | You didn't provide a client in the dblposter constructor (new poster("API_KEY", client) ) or in the bind function (bind(null, client) ) |
FAQs
A simple automatic poster for DiscordBotList
We found that dblposter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.