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
|
||||
|
||||
**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.
|
||||
|
||||
@@ -59,10 +62,9 @@ import { Bot, Command } from "commandbot";
|
||||
const bot = new Bot({
|
||||
name: "Command bot", // Name of your bot
|
||||
prefix: "!", // Prefix used to call commands
|
||||
argumentSeparator: ",", // Used to get arguments from message
|
||||
helpCommand: true, // Enable or disable the *help* command (optional)
|
||||
clientOptions: undefined, // Instance of ClientOptions from Discord.js
|
||||
token: "", // Bot token from Discord Developer Portal (optional, you can pass the token in *start* method)
|
||||
argumentSeparator: ",", // Used to get arguments from message (optional)
|
||||
clientOptions: undefined, // Instance of ClientOptions from Discord.js (optional)
|
||||
token: "", // Bot token from Discord Developer Portal (optional, you can pass the token in the *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))
|
||||
- **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))
|
||||
- **on** - _object_ - object containing function that trigger on specified events (see [Events](#events))
|
||||
|
||||
## Commands
|
||||
|
||||
@@ -251,6 +252,7 @@ All configuration parameters for messages are stored in _messages_ property (exa
|
||||
|
||||
Configuration parameters are stored in _messages.help_ property
|
||||
|
||||
- **enabled** - _boolean_ - enables or disables the help message
|
||||
- **title** - _string_ - title of help message
|
||||
- **bottomText** - _string_ - text shown below the title
|
||||
- **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",
|
||||
"version": "2.0.0-beta",
|
||||
"version": "2.0.0-beta2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "commandbot",
|
||||
"version": "2.0.0-beta",
|
||||
"version": "2.0.0-beta2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"discord.js": "^12.5.3"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "commandbot",
|
||||
"version": "2.0.0-beta",
|
||||
"version": "2.0.0-beta2",
|
||||
"description": "A framework that helps you create your own Discord bot easier.",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
||||
+7
-16
@@ -21,15 +21,10 @@ export declare interface Bot {
|
||||
): this;
|
||||
on(event: "error", listener: (e: any) => void): this;
|
||||
}
|
||||
interface ConfigurationOptions {
|
||||
token?: string;
|
||||
helpCommand: boolean;
|
||||
}
|
||||
interface ConstructorOptions {
|
||||
name: string;
|
||||
prefix: string;
|
||||
argumentSeparator?: string;
|
||||
helpCommand?: boolean;
|
||||
clientOptions?: ClientOptions;
|
||||
token?: string;
|
||||
}
|
||||
@@ -39,7 +34,7 @@ export class Bot extends EventEmitter {
|
||||
name: string;
|
||||
client: Client;
|
||||
commands: CommandManager;
|
||||
config: ConfigurationOptions;
|
||||
token: string;
|
||||
messages: {
|
||||
help: HelpMessageParams;
|
||||
system: SystemMessageManager;
|
||||
@@ -52,7 +47,6 @@ export class Bot extends EventEmitter {
|
||||
* @param {string} options.name - name of your bot
|
||||
* @param {string} options.prefix - prefix used to call commands
|
||||
* @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 {string} [options.token] - bot token from Discord Developer Portal
|
||||
*/
|
||||
@@ -64,13 +58,10 @@ export class Bot extends EventEmitter {
|
||||
options.prefix,
|
||||
options.argumentSeparator
|
||||
);
|
||||
this.config = {
|
||||
token: options.token,
|
||||
helpCommand:
|
||||
options.helpCommand != undefined ? options.helpCommand : true,
|
||||
};
|
||||
this.token = options.token || "";
|
||||
this.messages = {
|
||||
help: {
|
||||
enabled: true,
|
||||
title: "Help",
|
||||
description: "List of all available commands",
|
||||
color: "#ff5500",
|
||||
@@ -91,8 +82,8 @@ export class Bot extends EventEmitter {
|
||||
try {
|
||||
console.log(`Bot name: ${this.name}`);
|
||||
console.log(`Prefix: ${this.commands.prefix} \n`);
|
||||
const loginToken: string = token || this.config.token || "";
|
||||
if (loginToken === "") {
|
||||
this.token = token || this.token;
|
||||
if (this.token === "") {
|
||||
throw new ReferenceError(
|
||||
'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);
|
||||
}
|
||||
console.log("Starting modules...");
|
||||
if (this.config.helpCommand) {
|
||||
if (this.messages.help.enabled === true) {
|
||||
const helpMsg: Command = new HelpMessage(
|
||||
this.commands,
|
||||
this.messages.help,
|
||||
@@ -111,7 +102,7 @@ export class Bot extends EventEmitter {
|
||||
this.commands.add(helpMsg);
|
||||
}
|
||||
console.log("Connecting to Discord...");
|
||||
if (await this.client.login(loginToken)) {
|
||||
if (await this.client.login(this.token)) {
|
||||
this.client.on("ready", () => {
|
||||
this.emit("ready");
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ColorResolvable, MessageEmbed } from "discord.js";
|
||||
import { Command, CommandManager } from "./Command.js";
|
||||
|
||||
export interface HelpMessageParams {
|
||||
enabled: boolean;
|
||||
title: string;
|
||||
bottomText: string;
|
||||
color: ColorResolvable;
|
||||
|
||||
Reference in new issue
Block a user