-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCommandManager.js
52 lines (49 loc) · 1.7 KB
/
CommandManager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @fileoverview Neos.js Plugin - CommandManager
* @name neosjs-commands
* @author Bitman
* @returns {CommandManager}
* @see Parent Library: [Neos.js](https://github.com/PolyLogiX-Studio/Neos.js#readme)
*/
const CommandHandler = require("./CommandHandler");
const CommandExtended = require("./CommandExtended");
/**
*
* @class 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);
*/
class CommandManager {
/**
*
*
* @static
* @param {Neos.js} neos
* @param {*} CommandExtendedOptions
* @param {*} CommandHandlerOptions
* @returns {CommandExtended}
* @memberof CommandManager
*/
static CreateCommands(neos, CommandExtendedOptions, CommandHandlerOptions) {
return new CommandExtended(
new CommandHandler(neos, CommandHandlerOptions),
CommandExtendedOptions
);
}
}
module.exports = { CommandManager };