Giter Site home page Giter Site logo

thatsliams / discord.js-ghost-ping Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 3.0 245 KB

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

TypeScript 100.00%
discord-ghost-ping discordjs javascript npm-package

discord.js-ghost-ping's People

Contributors

criticalcarpet avatar dependabot[bot] avatar razesloth avatar thatsliams avatar

Stargazers

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

Watchers

 avatar

discord.js-ghost-ping's Issues

Suggestion: Throw Errors insead of Logging

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()\ ...`

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.