Skip to content

Commit 8986278

Browse files
committed
📖 DOC: Example Code
1 parent 01637a1 commit 8986278

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎.documentation.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ toc:
33
children:
44
- neosjs-commands
55
description: |
6-
This is a placeholder
6+
Plugin Library for [Neos.js](https://www.npmjs.com/package/@bombitmanbomb/neosjs)
77
- CommandManager

‎CommandManager.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ const CommandExtended = require("./CommandExtended");
1212
/**
1313
*
1414
* @class CommandManager
15+
* @example const CommandManager = require("neosjs-commands");
16+
* const Neos = new (require("@bombitmanbomb/neosjs"))
17+
* Command = CommandManager.Create(Neos)
18+
* Command.Add("Ping", (Handler)=>{Handler.Reply("Pong")})
19+
* Command.SetHelp("Ping", {index:"Ping Pong!", usage:Command.Options.Prefix+"Ping"})
20+
* Command.Add("Relay", (Handler, Sender, Args)=>{
21+
* if (Args.length<2) return Handler.Usage();
22+
* if (!Args[0].startsWith("U-")) return Handler.Reply("First Argument must be a UserID.");
23+
* if (!Neos.IsFriend(Args[0])) return Handler.Reply("User is not a Friend of the bot.");
24+
* Neos.SendTextMessage(Args.shift(), Args.join(" ")); // Remove first argument (UserID) and join the rest with spaces.
25+
* Handler.Reply("Message Sent!")
26+
* },
27+
* {
28+
* index:"Send a message to another user via the bot.",
29+
* usage:Command.Options.Prefix+"Relay <User-ID> <Message>"
30+
* }, ["U-BotOwner"]);
31+
* Neos.on("messageReceived", Command.Run);
1532
*/
1633
class CommandManager {
1734
/**

0 commit comments

Comments
 (0)