discordblacklist
Advanced tools
Comparing version 2.0.1 to 3.0.1
35
index.js
@@ -20,35 +20,6 @@ 'use strict'; | ||
* | ||
* @export Blacklist | ||
* @type {Blacklist} | ||
* @export | ||
* @type {Searcher} | ||
*/ | ||
exports.Blacklist = require('./lib/classes/Blacklist.discord').Blacklist; | ||
/** | ||
* An Object containing the three custom errors in case you would like to check for them. | ||
* See {@link module-ErrorEnum ErrorEnum} for more information. | ||
* | ||
* @export Errors | ||
* @type {Object} | ||
*/ | ||
exports.Errors = require('./lib/deps/ErrorEnum'); | ||
/** | ||
* The BanStore Class - In case you would like to create BanStores yourself. | ||
* See {@link BanStore} for more information. | ||
* | ||
* @export BanStore | ||
* @type {BanStore} | ||
*/ | ||
exports.BanStore = require('./lib/classes/BanStore').BanStore; | ||
/** | ||
* Various Package Constants. See {@link module-Constants Constants} | ||
* | ||
* @export Constants | ||
* @type {Object} | ||
*/ | ||
exports.Constants = require('./lib/deps/Constants'); | ||
module.exports = require('./src/struct/Searcher').default; |
{ | ||
"name": "discordblacklist", | ||
"version": "2.0.1", | ||
"version": "3.0.1", | ||
"description": "The Featured Nodejs package that facilitates getting banned Discord users from DiscordBans", | ||
@@ -8,9 +8,6 @@ "main": "index.js", | ||
"clean-nodem": "rm -rf ./node_modules", | ||
"test": "npm run lint; npm run generictest", | ||
"generictest": "node ./tests/generic/generaltest", | ||
"lint": "eslint lib examples *.js", | ||
"lint-fix": "eslint lib examples *.js --fix", | ||
"gen-doc": "jsdoc -r --verbose -d ./docs -c ./conf.json -R ./README.md .;", | ||
"lint": "eslint src *.js", | ||
"lint-fix": "eslint src *.js --fix", | ||
"clean-doc": "rm -rf ./docs; npm run gen-doc", | ||
"count-lines": "find ./lib -name '*.js' | xargs wc -l" | ||
"count-lines": "find ./src -name '*.js' | xargs wc -l" | ||
}, | ||
@@ -33,13 +30,3 @@ "repository": { | ||
"github": "https://github.com/wzhouwzhou/discordblacklist", | ||
"docs": "https://discordblacklist.willyz.cf/", | ||
"dependencies": { | ||
"snekfetch": "^3.5.8" | ||
}, | ||
"optionalDependencies": { | ||
"erlpack": "discordapp/erlpack" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.0.0", | ||
"jsdoc-strip-async-await": "^0.1.0" | ||
} | ||
"docs": "https://discordblacklist.willyz.cf/" | ||
} |
118
README.md
@@ -22,122 +22,36 @@ <div align="center"> | ||
or to use JSON only for stringifying/serializing (more info below) | ||
**Note: Version 3.x API has changed from previous versions, all previous versions are deprecated following a rewrite of the discordbans api as well as changed domains and removed features.** | ||
```$ npm install --save discordblacklist --no-optional``` | ||
**Note: Version 2.x API has changed from version 1.x to support DiscordBans v3 api. Version 2.x is not backwards compatible with version 1.x code. Package dependencies have also been updated so make sure you npm install properly.** | ||
The following contains documentation for discordblacklist 2.0.0, read the 1.0.7 (the latest 1.x) documentation [here](https://github.com/wzhouwzhou/discordblacklist/releases/tag/v1.0.7) | ||
### Quickstart: | ||
// Create the object (which autorefreshes the banlist every 120 minutes) | ||
const { Blacklist } = require('discordblacklist'); | ||
// Create the object | ||
const Blacklist = require('discordblacklist'); | ||
const token = 'My-token'; | ||
const blacklist = new Blacklist({ token, update: true }); | ||
const blacklist = new Blacklist(token); | ||
// Update the blacklist. | ||
await blacklist.update(); | ||
// Someone's id to test | ||
const someID = '1234567890'; | ||
// Check if they are on the banlist - Returns either null or the BannedUser. | ||
let user = blacklist.lookup(someID); | ||
// Raw data from the banlist | ||
let data = await blacklist.lookup(someID); | ||
console.log(data); | ||
// No await: | ||
blacklist.lookup(someID).then(result => console.log(result)); | ||
// Get the full list in string JSON form. Must be used after update() has completed | ||
const jsonified = blacklist.banstore.stringify(-1, true); | ||
console.log(jsonified); | ||
// Boolean they are on the banlist: | ||
let onTheList = await blacklist.isBanned(someID); | ||
console.log(onTheList); | ||
// No await: | ||
blacklist.isBanned(someID).then(result => console.log(result)); | ||
// If you installed optional dependencies (erlpack) use this. | ||
const bufferstring = blacklist.banstore.stringify(-1, false); | ||
console.log(bufferstring); | ||
// If you want an Array of BannedUser objects | ||
const array = blacklist.banstore.array(); | ||
// The first user on the banlist | ||
const banneduser = array[0]; | ||
const sameBanneduser = blacklist.banstore.get('1'); | ||
console.log(banneduser); | ||
### Setup and functions. | ||
**Exports:** | ||
`require('discordblacklist')` will return an Object with several keys: Blacklist, Errors, BanStore, and Constants. | ||
The Blacklist class can be set with | ||
const { Blacklist } = require('discordblacklist'); | ||
There are several ways to create an object from it, here's the simplest: | ||
const apiToken = '12345'; // Replace with actual token | ||
const blacklist = new Blacklist(apiToken); | ||
Get a token [here](https://bans.discordlist.net/mytoken). | ||
To update the list Manually | ||
const newlist = await blacklist.update(); | ||
To get the list quickly without updating unless the internal cache was deleted blacklist.fetchBanlist(); | ||
const list = await blacklist.fetchBanlist(); | ||
list and newList will contain a <BanStore> object which is a collection of BannedUser objects mapped by their banID. BannedUser objects have an id (userid), tag (discord tag), banID, bannedFor (reason), prooflink. | ||
Used normally (i.e. caching enabled), BanStores will always be stored inside blacklist.banstore | ||
To strip any class data and just get them in pure object form just run <BannedUser>.serialize() or <BanStore>.serialize(), and to stringify them <BannedUser> or <BanStore>.stringify(). | ||
**It is recommended you update your ban list every two hours** | ||
You can have the blacklist autoupdate at the recommended time like so: | ||
const banlist = new Blacklist({ token: 'something', update: true }); | ||
to customise the timer length (180 minutes in this example): | ||
const banlist = new Blacklist({ token: 'something', update: 180 }); | ||
to be completely explicit: | ||
const banlist = new Blacklist({ | ||
token: 'something', | ||
update: { | ||
autoupdate: true, | ||
minutes: 180, | ||
} | ||
}); | ||
**Looking up users.** | ||
Convenience shortcut (only works after if banlist has been fetched and cached): | ||
blacklist.lookup('id'); | ||
'id' is the userid of the user you want to check. This returns either a BannedUser or null depending on if the user is on the ban list. | ||
**Clearing and resetting your auto-updater** | ||
To clear the autoupdater simply call ``banlist.stopUpdateTimer();``. To then set a new one do ``banlist.setUpdateTimer(minutes)`` where minutes is an number. | ||
**Changing token** | ||
If for whatever reason you would like to switch tokens, you can do that easily by calling. | ||
```banlist.changeToken('newtoken');``` | ||
```blacklist.changeToken('newtoken');``` | ||
### Official examples for various frameworks and libraries are stored in the [examples](https://github.com/wzhouwzhou/discordblacklist/tree/master/examples) folder, visit the link to read more about them. | ||
This work is ©Copyright under the `GNU AFFERO GENERAL PUBLIC LICENSE Version 3`. See LICENSE for more details. | ||
### Further Documentation: | ||
[https://discordblacklist.willyz.cf/](https://discordblacklist.willyz.cf/) | ||
Enjoy this package? Consider starring on [github](https://github.com/wzhouwzhou/discordblacklist) and checking out some of my other work: | ||
[Youtube Search API](https://npmjs.com/ytsearcher) | ||
[Chips Discord Bot](https://chipsbot.me/) | ||
Contact William Zhou#0001 via https://discord.gg/jj5FzF7 for more information. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 10 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
0
2
2
46671
10
63
57
- Removedsnekfetch@^3.5.8
- Removedsnekfetch@3.6.4(transitive)