Archived
2.0.0-beta2
This commit is contained in:
1 parent
f14f5c8597
commit
283caba6cd
5 files changed
+19
-25
No files matched your search
@@ -1,6 +1,9 @@
|
|||||||
# CommandBot
|
# CommandBot
|
||||||
|
|
||||||
**2.0.0-beta**
|
**2.0.0-beta2**
|
||||||
|
|
||||||
|
> [IMPORTANT]
|
||||||
|
> Upgrading to this version from 1.1.3 may require additional changes in your code since 2.0.0 is not fully backwards compatible
|
||||||
|
|
||||||
Discord.js framework that helps you build your own Discord bot.
|
Discord.js framework that helps you build your own Discord bot.
|
||||||
|
|
||||||
@@ -59,10 +62,9 @@ import { Bot, Command } from "commandbot";
|
|||||||
const bot = new Bot({
|
const bot = new Bot({
|
||||||
name: "Command bot", // Name of your bot
|
name: "Command bot", // Name of your bot
|
||||||
prefix: "!", // Prefix used to call commands
|
prefix: "!", // Prefix used to call commands
|
||||||
argumentSeparator: ",", // Used to get arguments from message
|
argumentSeparator: ",", // Used to get arguments from message (optional)
|
||||||
helpCommand: true, // Enable or disable the *help* command (optional)
|
clientOptions: undefined, // Instance of ClientOptions from Discord.js (optional)
|
||||||
clientOptions: undefined, // Instance of ClientOptions from Discord.js
|
token: "", // Bot token from Discord Developer Portal (optional, you can pass the token in the *start* method)
|
||||||
token: "", // Bot token from Discord Developer Portal (optional, you can pass the token in *start* method)
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -86,7 +88,6 @@ The main object of this library has the following properties
|
|||||||
- **commands** - _CommandManager_ - base of the command system (see [Commands](#commands))
|
- **commands** - _CommandManager_ - base of the command system (see [Commands](#commands))
|
||||||
- **config** - _object_ - object that stores the login token and _helpMessage_ value from the constructor
|
- **config** - _object_ - object that stores the login token and _helpMessage_ value from the constructor
|
||||||
- **messages** - _SystemMessageManager_ - object instance containing all configuration parameters for built-in messages (see [Customization and built-in messages](#customization-and-built-in-messages))
|
- **messages** - _SystemMessageManager_ - object instance containing all configuration parameters for built-in messages (see [Customization and built-in messages](#customization-and-built-in-messages))
|
||||||
- **on** - _object_ - object containing function that trigger on specified events (see [Events](#events))
|
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
@@ -251,6 +252,7 @@ All configuration parameters for messages are stored in _messages_ property (exa
|
|||||||
|
|
||||||
Configuration parameters are stored in _messages.help_ property
|
Configuration parameters are stored in _messages.help_ property
|
||||||
|
|
||||||
|
- **enabled** - _boolean_ - enables or disables the help message
|
||||||
- **title** - _string_ - title of help message
|
- **title** - _string_ - title of help message
|
||||||
- **bottomText** - _string_ - text shown below the title
|
- **bottomText** - _string_ - text shown below the title
|
||||||
- **color** - _[ColorResolvable](https://discord.js.org/#/docs/main/stable/typedef/ColorResolvable)_ - color of the embedded content
|
- **color** - _[ColorResolvable](https://discord.js.org/#/docs/main/stable/typedef/ColorResolvable)_ - color of the embedded content
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "commandbot",
|
"name": "commandbot",
|
||||||
"version": "2.0.0-beta",
|
"version": "2.0.0-beta2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "commandbot",
|
"name": "commandbot",
|
||||||
"version": "2.0.0-beta",
|
"version": "2.0.0-beta2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord.js": "^12.5.3"
|
"discord.js": "^12.5.3"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "commandbot",
|
"name": "commandbot",
|
||||||
"version": "2.0.0-beta",
|
"version": "2.0.0-beta2",
|
||||||
"description": "A framework that helps you create your own Discord bot easier.",
|
"description": "A framework that helps you create your own Discord bot easier.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
+7
-16
@@ -21,15 +21,10 @@ export declare interface Bot {
|
|||||||
): this;
|
): this;
|
||||||
on(event: "error", listener: (e: any) => void): this;
|
on(event: "error", listener: (e: any) => void): this;
|
||||||
}
|
}
|
||||||
interface ConfigurationOptions {
|
|
||||||
token?: string;
|
|
||||||
helpCommand: boolean;
|
|
||||||
}
|
|
||||||
interface ConstructorOptions {
|
interface ConstructorOptions {
|
||||||
name: string;
|
name: string;
|
||||||
prefix: string;
|
prefix: string;
|
||||||
argumentSeparator?: string;
|
argumentSeparator?: string;
|
||||||
helpCommand?: boolean;
|
|
||||||
clientOptions?: ClientOptions;
|
clientOptions?: ClientOptions;
|
||||||
token?: string;
|
token?: string;
|
||||||
}
|
}
|
||||||
@@ -39,7 +34,7 @@ export class Bot extends EventEmitter {
|
|||||||
name: string;
|
name: string;
|
||||||
client: Client;
|
client: Client;
|
||||||
commands: CommandManager;
|
commands: CommandManager;
|
||||||
config: ConfigurationOptions;
|
token: string;
|
||||||
messages: {
|
messages: {
|
||||||
help: HelpMessageParams;
|
help: HelpMessageParams;
|
||||||
system: SystemMessageManager;
|
system: SystemMessageManager;
|
||||||
@@ -52,7 +47,6 @@ export class Bot extends EventEmitter {
|
|||||||
* @param {string} options.name - name of your bot
|
* @param {string} options.name - name of your bot
|
||||||
* @param {string} options.prefix - prefix used to call commands
|
* @param {string} options.prefix - prefix used to call commands
|
||||||
* @param {string} [options.argumentSeparator=','] - used to get arguments from message
|
* @param {string} [options.argumentSeparator=','] - used to get arguments from message
|
||||||
* @param {boolean} [options.helpCommand = true] - enable or disable the *help* command
|
|
||||||
* @param {ClientOptions} [options.clientOptions] - client options from Discord.js
|
* @param {ClientOptions} [options.clientOptions] - client options from Discord.js
|
||||||
* @param {string} [options.token] - bot token from Discord Developer Portal
|
* @param {string} [options.token] - bot token from Discord Developer Portal
|
||||||
*/
|
*/
|
||||||
@@ -64,13 +58,10 @@ export class Bot extends EventEmitter {
|
|||||||
options.prefix,
|
options.prefix,
|
||||||
options.argumentSeparator
|
options.argumentSeparator
|
||||||
);
|
);
|
||||||
this.config = {
|
this.token = options.token || "";
|
||||||
token: options.token,
|
|
||||||
helpCommand:
|
|
||||||
options.helpCommand != undefined ? options.helpCommand : true,
|
|
||||||
};
|
|
||||||
this.messages = {
|
this.messages = {
|
||||||
help: {
|
help: {
|
||||||
|
enabled: true,
|
||||||
title: "Help",
|
title: "Help",
|
||||||
description: "List of all available commands",
|
description: "List of all available commands",
|
||||||
color: "#ff5500",
|
color: "#ff5500",
|
||||||
@@ -91,8 +82,8 @@ export class Bot extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
console.log(`Bot name: ${this.name}`);
|
console.log(`Bot name: ${this.name}`);
|
||||||
console.log(`Prefix: ${this.commands.prefix} \n`);
|
console.log(`Prefix: ${this.commands.prefix} \n`);
|
||||||
const loginToken: string = token || this.config.token || "";
|
this.token = token || this.token;
|
||||||
if (loginToken === "") {
|
if (this.token === "") {
|
||||||
throw new ReferenceError(
|
throw new ReferenceError(
|
||||||
'No token specified. Please pass your Discord application token as an argument to the "start" method or in the constructor'
|
'No token specified. Please pass your Discord application token as an argument to the "start" method or in the constructor'
|
||||||
);
|
);
|
||||||
@@ -102,7 +93,7 @@ export class Bot extends EventEmitter {
|
|||||||
http.createServer().listen(port);
|
http.createServer().listen(port);
|
||||||
}
|
}
|
||||||
console.log("Starting modules...");
|
console.log("Starting modules...");
|
||||||
if (this.config.helpCommand) {
|
if (this.messages.help.enabled === true) {
|
||||||
const helpMsg: Command = new HelpMessage(
|
const helpMsg: Command = new HelpMessage(
|
||||||
this.commands,
|
this.commands,
|
||||||
this.messages.help,
|
this.messages.help,
|
||||||
@@ -111,7 +102,7 @@ export class Bot extends EventEmitter {
|
|||||||
this.commands.add(helpMsg);
|
this.commands.add(helpMsg);
|
||||||
}
|
}
|
||||||
console.log("Connecting to Discord...");
|
console.log("Connecting to Discord...");
|
||||||
if (await this.client.login(loginToken)) {
|
if (await this.client.login(this.token)) {
|
||||||
this.client.on("ready", () => {
|
this.client.on("ready", () => {
|
||||||
this.emit("ready");
|
this.emit("ready");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ColorResolvable, MessageEmbed } from "discord.js";
|
|||||||
import { Command, CommandManager } from "./Command.js";
|
import { Command, CommandManager } from "./Command.js";
|
||||||
|
|
||||||
export interface HelpMessageParams {
|
export interface HelpMessageParams {
|
||||||
|
enabled: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
bottomText: string;
|
bottomText: string;
|
||||||
color: ColorResolvable;
|
color: ColorResolvable;
|
||||||
|
|||||||
Reference in new issue
Block a user