Coder Social home page Coder Social logo

ottrone / lexbot Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 258 KB

LexBot in TypeScript. Originally a v12 template, the bot got ported to discord.js v13 supporting Slash commands.

License: MIT License

TypeScript 99.92% Shell 0.08%
discord-bot discordjs v13 typescript discord bot

lexbot's Introduction

GitHub license Maintained GitHub open issues

LexBot

A port of the LexBot Discord bot template to discord.js v13 and TypeScript.

Setup

  1. Install all dependencies via npm install after cloning the repo.

  2. Rename the example.env file to .env and add your Discord bot token.

TOKEN=
DEBUG=True

.env is part of the .gitignore file so changes won't be committed.

Production environment: remove the DEBUG line in the .env

npm Commands

Command Description
npm run prebuild Extract version from package.json.
npm run build Build the typescript code.
npm run lint Runs the linter on the code.
npm run start Runs the bot from the built JavaScript.
npm run debug Debug the TypeScript in watch mode.

Adding new commands

To add new commands add a .ts file in /commands/ or any subdirectory of /commands/. The command implements the Command interface with the following required properties:

export = {
    name: '',
    category: '',
    description: '',
    run: ({  }: CallbackOptions) => {
        // do stuff
    }
} as Command;

Check the CallbackOptions interface for possible properties. member is available for every CommandType. message and args are only available for NORMAL commands aka !commands while interaction is only available for SLASH commands.

Its mandatory to define the type if it's supposed to be SLASH command only

Example:

import { Command, CommandType } from '../interfaces/command';
import { CallbackOptions } from '../interfaces/CallbackOptions';

export = {
    name: 'ping',
    type: CommandType.SLASH,
    category: 'LexBot',
    description: 'Sends back pong',
    run: ({ interaction }: CallbackOptions) => {

        if (!interaction) return;
        interaction.reply('Pong!');
    },
} as Command;

Is the type set to SLASH or BOTH it will be added dynamically to the Discord command list. (Remember to set up a proper run function for it)

Writing a mod

(coming soon)

lexbot's People

Contributors

aottr avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.