Update documentation
This commit is contained in:
parent
e9112ee00e
commit
a5123d6f79
1 changed files with 80 additions and 21 deletions
101
README.md
101
README.md
|
@ -6,39 +6,98 @@ Discord bot client based upon Discord.js
|
||||||
|
|
||||||
Download the latest version from the [releases page](https://gitlab.vylpes.com/Vylpes/vylbot-core/-/releases).
|
Download the latest version from the [releases page](https://gitlab.vylpes.com/Vylpes/vylbot-core/-/releases).
|
||||||
|
|
||||||
Copy the config template file and fill in the strings.
|
Copy the config template file and fill in the values.
|
||||||
|
|
||||||
```json
|
```env
|
||||||
{
|
BOT_TOKEN={TOKEN}
|
||||||
"token": "",
|
BOT_PREFIX=v!
|
||||||
"prefix": "",
|
|
||||||
"commands": [
|
FOLDERS_COMMANDS=commands
|
||||||
""
|
FOLDERS_EVENTS=events
|
||||||
],
|
|
||||||
"events": [
|
|
||||||
""
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* **Token:** Your bot's token
|
* **BOT_TOKEN:** Your bot's token, replace {TOKEN} with your bot token
|
||||||
* **Prefix** The command prefix
|
* **BOT_PREFIX** The command prefix
|
||||||
* **Commands:** An array of the folders which contain your commands
|
* **FOLDERS_COMMANDS:** The folder which contains your commands
|
||||||
* **Events:** An array of the folders which contain your events
|
* **FOLDERS_EVENTS** The folder which contains your events
|
||||||
|
|
||||||
|
Make sure that you **DO NOT** put your .env file into VCS!
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Implement the client using something like:
|
Implement the client using something like:
|
||||||
|
|
||||||
```js
|
```ts
|
||||||
const vylbot = require('vylbot-core');
|
// bot.ts
|
||||||
const config = require('config.json');
|
|
||||||
|
|
||||||
const client = new vylbot.client(config);
|
import { CoreClient } from "vylbot-core";
|
||||||
|
|
||||||
|
const client = new CoreClient();
|
||||||
client.start();
|
client.start();
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [docs](https://gitlab.vylpes.com/Vylpes/vylbot-core/-/wikis/home) for more information on how to use vylbot-core
|
### Writing Commands
|
||||||
|
|
||||||
|
The code below will reply to the user with 'PONG' when they type {PREFIX}ping
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Ping.ts
|
||||||
|
|
||||||
|
import { Command, ICommandContext } from "vylbot-core";
|
||||||
|
|
||||||
|
export class Ping extends Command {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this._roles = [ "Moderator" ];
|
||||||
|
this._category = "General";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override execute(context: ICommandContext) {
|
||||||
|
context.message.reply('PONG');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* **roles**: An array containing what roles the user needs in order to run the command.
|
||||||
|
* **category**: The category the role is part of, useful for categorising commands together in a help command.
|
||||||
|
|
||||||
|
The `context` parameter contains the following:
|
||||||
|
* **name**: The command name
|
||||||
|
* **args**: An array of arguments supplied with the command
|
||||||
|
* **message**: The Discord Message object for the command message sent
|
||||||
|
|
||||||
|
### Writing Events
|
||||||
|
|
||||||
|
The code below will log to the console 'Member Joined: {USERNAME}' when a member joins a server the bot is in
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Moderation.ts
|
||||||
|
|
||||||
|
import { Event } from "vylbot-core";
|
||||||
|
import { GuildMember } from "discord.js";
|
||||||
|
|
||||||
|
export class Moderation extends Event {
|
||||||
|
public override guildMemberAdd(member: GuildMember) {
|
||||||
|
console.log(`Member Joined: ${member.tag}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The following events are supported:
|
||||||
|
* channelCreate(channel: Channel)
|
||||||
|
* channelDelete(channel: Channel | PartialDMChannel)
|
||||||
|
* channelUpdate(oldChannel: Channel, newChannel: Channel)
|
||||||
|
* guildBanAdd(guild: Guild, user: User)
|
||||||
|
* guildBanRemove(guild: Guild, user: User)
|
||||||
|
* guildCreate(guild: Guild)
|
||||||
|
* guildMemberAdd(member: GuildMember)
|
||||||
|
* guildMemberRemove(member: GuildMember | PartialGuildMember)
|
||||||
|
* guildMemberUpdate(oldMember: GuildMember | PartialGuildMember, newMember: GuildMember)
|
||||||
|
* message(message: Message)
|
||||||
|
* messageDelete(message: Message | PartialMessage)
|
||||||
|
* messageUpdate(oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage)
|
||||||
|
|
||||||
|
All parameters are supplied from discord.js
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
Reference in a new issue