# vylbot-core

> A discord client based upon discord.js

Latest version **2.0.3** (published 2021-12-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install vylbot-core
pnpm add vylbot-core
yarn add vylbot-core
bun add vylbot-core
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2021-12-02 |
| First published | 2020-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 224.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vylpes |
| Maintainers | vylpes |
| Keywords | discord, bot, client |

## Links

- npm: https://www.npmjs.com/package/vylbot-core
- Repository: https://github.com/vylpes/vylbot-core
- Issues: https://github.com/vylpes/vylbot-core/issues
- Funding: https://ko-fi.com/vylpes
- npm.io page: https://npm.io/package/vylbot-core

## Dependencies (2)

- [dotenv](https://npm.io/package/dotenv.md) ^10.0.0
- [discord.js](https://npm.io/package/discord.js.md) ^12.3.1

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2021-12-02
- 2.0.2 — 2021-11-25
- 2.0.1 — 2021-10-11
- 2.0.0 — 2021-10-04
- 1.0.5 — 2021-06-26
- 1.0.4 — 2020-10-23
- 1.0.3 — 2020-10-23
- 1.0.2 — 2020-10-23
- 1.0.1 — 2020-10-23
- 1.0.0 — 2020-10-20

## README

# VylBot Core

Discord bot client based upon Discord.js 

## Installation

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 values.

```env
BOT_TOKEN={TOKEN}
BOT_PREFIX=v!

FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events

COMMANDS_DISABLED=
COMMANDS_DISABLED_MESSAGE=This command is disabled.
```

* **BOT_TOKEN:** Your bot's token, replace {TOKEN} with your bot token.
* **BOT_PREFIX:** The command prefix.
* **FOLDERS_COMMANDS:** The folder which contains your commands.
* **FOLDERS_EVENTS:** The folder which contains your events.
* **COMMANDS_DISABLED:** List of command file names that won't run, separated by commas.
* **COMMANDS_DISABLED_MESSAGE:** The message which is replied to the user who tries to run a disabled command.

Make sure that you **DO NOT** put your .env file into VCS!

## Usage

Implement the client using something like:

```ts
// bot.ts

import { CoreClient } from "vylbot-core";

const client = new CoreClient();
client.start();
```

### 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 default 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)
* ready()

All parameters are supplied from discord.js

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

We will not merge pull requests unless all checks pass and at least one of the repo members approves it.

See CONTRIBUTING.md for more details.

---
_Source: https://npm.io/package/vylbot-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
