diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..f4447cd --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,21 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: neosjs-commands Publish + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/docs/index.html b/docs/index.html index cb96e5a..8ff21f4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ - neosjs-commands 1.0.1 | Documentation + neosjs-commands 1.0.2 | Documentation @@ -15,7 +15,7 @@

neosjs-commands

-
1.0.1
+
1.0.2
neosjs-commands
  • - - CommandHandler + + CommandExtended
  • - - CommandExtended + + CommandHandler -

    This is a placeholder

    +

    + Plugin Library for + Neos.js +

    Neos.js Plugin - Commands
    @@ -225,6 +230,28 @@

    CommandManager

    new CommandManager()
    +
    Example
    + +
    const CommandManager = require("neosjs-commands");
    +const Neos = new (require("@bombitmanbomb/neosjs"))
    +Command = CommandManager.Create(Neos)
    +Command.Add("Ping", (Handler)=>{Handler.Reply("Pong")})
    +Command.SetHelp("Ping", {index:"Ping Pong!", usage:Command.Options.Prefix+"Ping"})
    +Command.Add("Relay", (Handler, Sender, Args)=>{
    + if (Args.length<2) return Handler.Usage();
    + if (!Args[0].startsWith("U-")) return Handler.Reply("First Argument must be a UserID.");
    + if (!Neos.IsFriend(Args[0])) return Handler.Reply("User is not a Friend of the bot.");
    + Neos.SendTextMessage(Args.shift(), Args.join(" ")); // Remove first argument (UserID) and join the rest with spaces.
    + Handler.Reply("Message Sent!")
    +},
    +{
    + index:"Send a message to another user via the bot.",
    + usage:Command.Options.Prefix+"Relay <User-ID> <Message>"
    +}, ["U-BotOwner"]);
    +Neos.on("messageReceived", Command.Run);
    +
    Static Members
    @@ -280,38 +307,45 @@

    CommandManager

    -

    CommandHandler

    +

    CommandExtended

    -

    CommandHandler Plugin.

    +

    CommandExtended Plugin. Adds more features to CommandHandler

    - new CommandHandler(NeosJS: Class, Invalid: - String) + new CommandExtended(CommandHandler: + CommandHandler, Options: {Prefix: + "/", HelpCommand: "help", UsageCommand: + "usage", CommandsCommand: "commands", + HelpDefault: + "Get a list of commands with $this.prefix + + $this.CommandsCommand"})
    Parameters
    - NeosJS - (Class) - Neos.js "this" instance + CommandHandler + (CommandHandler)
    - Invalid + Options (String - = "Invalid Command")({Prefix: "/", HelpCommand: "help", + UsageCommand: "usage", CommandsCommand: + "commands", HelpDefault: + "Get a list of commands with $this.prefix + + $this.CommandsCommand"})
    @@ -321,37 +355,48 @@

    CommandHandler

    const NEOS = require("@bombitmanbomb/neosjs")
    +					>const CommandHandler = require("@bombitmanbomb/neosjs/Plugins/CommandHandler")
    +const CommandExtended = require("@bombitmanbomb/neosjs/Plugins/CommandExtended")
    +const NEOS = require("@bombitmanbomb/neosjs")
     const Neos = new NEOS()
    -const CommandHandler = require("@bombitmanbomb/neosjs/Plugins/CommandHandler")
    -const Command = new Commandhandler(Neos)
    -Command.Add("Ping", (Handler)=>{Handler.Reply("Pong!")});
    -Neos.on("messageReceived", (Message)=>{
    -	Command.Run(Message)
    -})
    +const Command = new CommandExtended(new CommandHandler(Neos),Options); +Command.Add("Ping", (Handler)=>{Handler.Reply("Pong")}) +Command.SetHelp("Ping", {index:"Ping Pong!", usage:Command.Options.Prefix+"Ping"}) +Command.Add("Relay", (Handler, Sender, Args)=>{ + if (Args.length<2) return Handler.Usage(); + if (!Args[0].startsWith("U-")) return Handler.Reply("First Argument must be a UserID."); + if (!Neos.IsFriend(Args[0])) return Handler.Reply("User is not a Friend of the bot."); + Neos.SendTextMessage(Args.shift(), Args.join(" ")); // Remove first argument (UserID) and join the rest with spaces. + Handler.Reply("Message Sent!") +}, +{ + index:"Send a message to another user via the bot.", + usage:Command.Options.Prefix+"Relay <User-ID> <Message>" +}, ["U-BotOwner"]); +Neos.on("messageReceived", Command.Run); -
    Static Members
    +
    Instance Members
    -
    +
    Add(command, cb, whitelist?)Add(Command, Script, Help, Whitelist?)
    -
    +
    +
    +
    + + Run(Message) +
    +
    + +
    + +
    Run(Message, Extra)SetHelp(Command, Help)