thatsliams / discord.js-ghost-ping Goto Github PK
View Code? Open in Web Editor NEWDetect Ghost Pings inside of discord.js, with tens of thousands of NPM downloads!
Home Page: https://npmjs.com/package/discord.js-ghost-ping
License: MIT License
Detect Ghost Pings inside of discord.js, with tens of thousands of NPM downloads!
Home Page: https://npmjs.com/package/discord.js-ghost-ping
License: MIT License
Whenever an argument is missing or something goes wrong the code currently just does console.log
. While this is great for telling someone what went wrong, it can cause a problem if someone's program was to do an action based on this. I suggest throwing a custom error instead. This way, one can import the error and, if they want, use try and catch specifically for that or do something in there program differently if it does not succeed.
This is an example of what I mean. (with some removed code)
// discord.js-ghost-ping
class ParameterError extends Error {
constructor(...params) {
super(...params)
this.name = "ParameterError"
}
}
const ErrorMessages = {
expectedParameterError: new ParameterError (`\ndiscordjs-ghost-ping: expected parameter (EventType) in dectector()\n\ndiscord.js#client.on(\"messageDelete\", message => {\n ^\n |\n(EventType) is \'messageDelete\'\n`),
...
}
... {
if (eventType === undefined) throw ErrorMessages.expectedParameterError
}
// mybot.js
...
client.on('messageDelete', message => {
// lets say something goes wrong here (misspelled on purpose)
GhostPing.detector('mesageDelete', message)
// One would get this error and know that something in the code is wrong
// ParameterError: `\ndiscordjs-ghost-ping: unexpected parameter (EventType) in dectector()\ ...`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.