This repository has been archived on 2023-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
Find a file
2021-08-20 15:58:41 +01:00
.github Update FUNDING.yml 2021-05-10 21:51:29 +01:00
.gitlab Update default.md 2021-01-15 18:15:59 +00:00
src More tests 2021-08-19 17:27:47 +01:00
tests Improvements to Tests 2021-08-20 15:53:34 +01:00
.env.template Rewrite in TypeScript 2021-07-14 13:55:36 +01:00
.eslintignore Add ESLint 2021-08-20 15:58:41 +01:00
.eslintrc Add ESLint 2021-08-20 15:58:41 +01:00
.gitignore First util.ts test 2021-08-19 17:21:54 +01:00
.gitlab-ci.yml Tests 2021-01-16 19:06:35 +00:00
.npmignore Rewrite in TypeScript 2021-07-14 13:55:36 +01:00
CODE_OF_CONDUCT.md Update documentation with a contact email 2020-11-07 11:22:43 +00:00
CONTRIBUTING.md Adjust links 2020-11-07 21:23:14 +00:00
jest.config.js Add client tests 2021-07-30 15:49:12 +01:00
LICENSE Initial commit 2020-10-20 10:42:08 +01:00
package.json Add ESLint 2021-08-20 15:58:41 +01:00
README.md Add ready event 2021-07-22 17:52:36 +01:00
tsconfig.json Add client tests 2021-07-30 15:49:12 +01:00
yarn.lock Add ESLint 2021-08-20 15:58:41 +01:00

VylBot Core

Discord bot client based upon Discord.js

Installation

Download the latest version from the releases page.

Copy the config template file and fill in the values.

BOT_TOKEN={TOKEN}
BOT_PREFIX=v!

FOLDERS_COMMANDS=commands
FOLDERS_EVENTS=events
  • 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

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

Usage

Implement the client using something like:

// 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

// 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

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