MarcusCemes / discord-bot

A fun little Discord bot experiment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Logo

Time to Bot

A fun little Discord bot experiment
Add to your server »

Table of Contents

About The Project

This is the source code for my little Discord bot experiment. It tells jokes, insults people and plays Chameleon. Dig around!

Built With

Getting Started

You may either try to add the official bot directly to your server, or you may make your own copy. Please note that there is absolutely no uptime guarantee.

If you don't trust adding a random bot, or would like to host it yourself, you may clone this repository and build the code yourself! Running the code is like running the Discord client, the bot can only respond if the code is running!

The following instructions will try and help you build and run your own copy.

Prerequisites

You will need a Node.js runtime that you can get from this website.

You will also need to set up an app and associated bot on Discord's development portal, in order to acquire a Discord Token. This token is used to identify and authorise the connection to Discord as the bot you just created.

You may provide this token either through an environmental variable DISCORD_TOKEN, or by placing it in an .env file in the root of this project directory using the format DISCORD_TOKEN=... . Note that by using the .env approach, you must run the code using one of the npm scripts that automatically load and inject the .env variables into Node.js (or setup dotenv yourself).

Installation

  1. Clone the repo
$ git clone https://github.com/MarcusCemes/discord-bot.git
  1. Install NPM packages
$ npm ci
  1. Build the source
$ npm run build
  1. Set an environmental variable with your obtained discord token
$ export DISCORD_TOKEN=...    # Linux/OSX
$ SET DISCORD_TOKEN=...       # Windows

or populate the .env file     # Cross-platform, also persistent
  1. Start the bot!
$ npm start

Your bot is now online! You will need to add it to a server (I recommend this website to help setup the join link) and give it some permissions.

To get live-reloading, you may use npm run develop. If you use VSCode, this project also has a debug profile set up, just press F5.

Usage

The bot will respond to messages that either start with the command delimiter (currently "$"), or that mention the bot directly (with @name_of_bot) somewhere in the message.

The bot analyses messages by trying to loosely match keywords to the message content to try and guess the user's intent. Here is a (possibly incomplete) list of supported actions, and some example keywords. For a full list, see the source code.

Action Example triggers Description
GREET hey, hi Replies with a friendly greeting
JOKE joke, funny Fetches a joke from a Joke API
INSULT insult, mean Fetches an insult from an Insult API (requires a mention)
CHAMELEON chameleon A custom game, requires a 4x4 table of words.

Here are some example messages you can try!

@bot_name, tell me a joke!

$ Hey! How are you?

@bot_name, say something mean to @user_name

License

Distributed under the MIT License. See LICENSE for more information.


This is an educational experiment, use at your own risk!

About

A fun little Discord bot experiment

License:MIT License


Languages

Language:TypeScript 100.0%