The One beneath the Supreme Overlord's rule.

Overview

CSBot

(Proper name TBD)

This project is undergoing rapid development and should be considered experimental. Use it at your own risk. 🤙

Authors & Contributors

This list is updated as contributors contribute.

Table of contents

Usage or Development

Prerequisites

This project requires NodeJS (version 16.10 or later), NPM. To make sure you have them available on your machine, try running the following command:

$ npm -v && node -v
7.20.3
v16.15.1

Clone the Repo

$ cd path/to/parent
$ git clone https://github.com/BYU-CS-Discord/CSBot.git
$ cd CSBot

Get your own bot token

Note that, by running this bot, you agree to be bound by the Discord's Developer Terms of Service and Developer Policy, as well as this project's own license. With that in mind, you'll need a token for a Discord bot account. See this awesome tutorial on how to get one.

Configure the bot

Create a file called .env in the root of this project folder. Paste your token into that file, and fill in other config items as desired:

# .env

DISCORD_TOKEN=YOUR_TOKEN_GOES_HERE
# required, token for your Discord bot

Do not commit this file to git or your bot will get "hacked".

Invite your bot to your server

Go to https://discordapi.com/permissions.html#378091424832 and paste in your bot's client ID to get an invite link.

Important Note for Windows Users

If you're on Windows, npm scripts will not work unless you tell npm to use Git Bash as its default shell when running commands.

Before continuing, run this command:

$ npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"

You must have Git for Windows installed. See this StackOverflow answer for more details.

Build the bot server

Be sure to install dependencies, and run a quick lint to generate needed files:

$ npm ci
$ npm run lint

The first time you download the source, and each time the source code changes, you'll need to run this command before you run the bot:

$ npm run build

Register Slash Commands

If you want support for Discord Slash Commands, you'll need to deploy the commands directly. To avoid rate limits, use a command-line tool, rather than deploying on startup.

Once you have your bot's account token in the .env file, run the following command to tell Discord about our commands:

$ npm run commands:deploy

Run the bot

Since this bot is just a Node script, any Node process manager will do.

$ node .
# or
$ npm start
# or
$ pm2 start .

Commands

/help

Prints the list of commands.

Contributing

This project is entirely open-source. Do with it what you will. If you're willing to help me improve this project, consider filing an issue.

See CONTRIBUTING.md for ways to contribute.

License

This project's source is licensed under the Unlicense license. All contributions thereto are given to the public domain.

Comments
  • Added a 'Fix Twitter Links' context menu item

    Added a 'Fix Twitter Links' context menu item

    • New context menu item sends an ephemeral message with better versions of Twitter links
    • Adds basic bones for context-menu commands, similar to the way chat-input (slash) commands work
    • Fixed some cases of hard-coded formatting, using Discord.js's tools

    Closes #45

    enhancement 
    opened by AverageHelper 7
  • Use Builders for Commands

    Use Builders for Commands

    This should make commands be fully functional (subcommands, context menu commands, etc) and easier to implement. The unit tests should also be passing.

    enhancement 
    opened by SpencerHastings 7
  • Basic command context

    Basic command context

    Added

    • Discord client
    • Event handling
    • Command dispatcher
    • Lots of unit tests
    • Some fixes to the dev environment, making ESLint and Prettier fight less

    The test coverage is "ok," but could be improved. I added a CI check to make coverage clear and keep us accountable.

    Closes #7

    opened by AverageHelper 7
  • Create bot account & add to dev server

    Create bot account & add to dev server

    • who should own the bot account?

    • can the bot be easily transferred between discord accounts in the future?

    • how to safely distribute the token for testing purposes?

    opened by AverageHelper 5
  • Event Handler Abstraction

    Event Handler Abstraction

    This is a chonky pull request. Lots of new files, and lots of little edits all over the place.

    • Added a new type for Event Handlers
    • Added a ./events folder with an index.ts that gathers all event files, similar to ./commands
    • Moved all event handlers out of main.ts and into individual event files
    • Moved all event handler testing code out of main.test.ts into individual test files
    • Moved command-handling code from handleInteraction.ts into the interactionCreate event file
    • Updated all affected test files
    • Wrote new tests for all new code - 100% coverage on all additions
    • On the side, I made xkcd.test.ts mock the logger file like the other tests

    There's a lot here, so I'm sure it's a little messy. Don't be shy with requesting changes.

    Closes #28

    enhancement 
    opened by JstnMcBrd 4
  • Reaction duplication

    Reaction duplication

    When users add reactions to messages, the bot will some fraction of the time, also react with that same reaction.

    /set-reaction-rate <rate> [emoji] sets how often the bot reacts. If emoji is not specified, this will set the default reaction rate for all reactions, which can be overriden on a reaction-by-reaction basis by specifying emoji. rate is a simple fractional number like 0.1. If this command has not been run yet, set the default reaction rate to 0.05.

    /get-reaction-rate [emoji] prints the set rate for either the default or a specific emoji. If no specific rate is set for an emoji, show the default and indicate that it is is the default.

    enhancement 
    opened by Plyb 4
  • Basic `/help` functionality

    Basic `/help` functionality

    At its very basic, /help lists the commands available to the user. This is at least a start.

    Screen Shot 2022-09-28 at 23 23 19

    This command will automatically include new commands as they're added in src/commands/index.ts.

    Closes #8

    opened by AverageHelper 4
  • Simplify `CommandContext` construction

    Simplify `CommandContext` construction

    @JstnMcBrd made a good point in #14 that handleInteraction is a hekkin chonker of a function.

    I think that function should be in charge of constructing the context, since that's a natural part of executing a command, which is the primary job of the handleInteraction function. The methods (prepareForLongRunningTasks, reply, followUp, etc.) could be moved away, using something like a function factory, without breaking the context interface. We can't just move the functions directly, since they rely on the interaction metadata from the specific command invocation, but a factory could encapsulate the relevant logic while leaving handleInteraction to do the main business of constructing and dispatching the wider context.

    enhancement 
    opened by AverageHelper 4
  • Logger abstraction

    Logger abstraction

    The logger was already partially abstracted before, but it required passing logger around through parameters in methods. This was causing problems for event handler abstraction.

    Now the logger is in a separate file called logger.ts that contains a method that returns the logger to use (the console, for now). We use a method instead of a constant to make mocking easier for tests.

    All files that used the logger before now pull the logger from logger.ts instead of passing through parameters. I also updated tests to reflect this fact by mocking logger.ts.

    enhancement 
    opened by JstnMcBrd 3
  • Create Basic Database Schema

    Create Basic Database Schema

    (Posited by @ZYancey)

    Many stories (Starboard, Tracking, Smites) depend on a Database, establishing this should be a high priority as it will unlock future work It could be nice if it regularly created snapshots of the database on a schedule or through a slash command.

    enhancement 
    opened by AverageHelper 3
  • Slash Command - xkcd search

    Slash Command - xkcd search

    /xkcd should post a link with the most recent xkcd comic. /xkcd [query] should search for xkcd comics and post the best match

    Dev notes: Perhaps look at how Ze Kaiser did this to get ideas on the search

    enhancement 
    opened by Plyb 3
  • 10 Tagging System

    10 Tagging System

    Tags at a minimum viable stage. Not close to ready for merge. Mostly just for reference at this point but following next week I should be able to clean things up.

    opened by ZYancey 0
  • Automatic ephemeral reply to advise users to use fxtwitter links

    Automatic ephemeral reply to advise users to use fxtwitter links

    Copied from a discussion in #dev. See there for more details.

    Instead of the bot automatically replacing the user's message when it detects a twitter.com link, how about it sends an ephemeral reply advising the user to edit their message to use fxtwitter.com?

    Hi there! I noticed you posted a twitter link. Did you know you can improve the embed by editing your message to use fxtwitter.com instead of twitter.com?

    Or something shorter like

    Pro tip: replace twitter.com with fxtwitter.com for a better discord embed!

    Or something more assertive

    Please replace twitter.com with fxtwitter.com for an improved embed.

    Or something goofy

    Uh oh, looks like you posted a default twitter link. Such a terrible embed. That's really embarrassing. Better edit your message before anyone notices. Quick, replace twitter.com with fxtwitter.com!

    opened by JstnMcBrd 0
  • Slash Command - APOD search

    Slash Command - APOD search

    Similar to the /xkcd command, we could easily add a command to fetch the Astronomy Picture of the Day.

    NASA has an open API for APOD, and there's also some node module wrappers to make it easy. Here's the best one I found.

    Just like the /xkcd command, it could fetch the current APOD or any APOD from the past, all the way back to 1996.

    opened by JstnMcBrd 0
  • Slash command - retrieve emoji images

    Slash command - retrieve emoji images

    The purpose of the /emoji command would be similar to /profile - return the internal image used for a custom emoji.

    Discord.js has this functionality with the Emoji.url property.

    enhancement 
    opened by JstnMcBrd 3
Owner
BYU CS Discord
Developers of software for the "BYU CS" Discord server.
BYU CS Discord
Rule YouTube, Soundcloud and Vimeo player with one API

Polyplayer Polyplayer allows you to rule YouTube's, Soundcloud's and Vimeo's player using one API. Features Playing, pausing, stopping Seek to absolut

Marius 41 Sep 24, 2022
A multipurpose bot, a clan bot, a all in one bot. The one bot u need for ur server originally made as Milrato discord Bot and by Tomato6966.

Public Bot and Support Server! Invite the Public Version of this Bot so you don't need to host it by yourself or join my Discord server to get a custo

Tomato6966 472 Dec 25, 2022
🔊 first auto join discord selfbot - just with one command join it to your server 🔥

?? Messi (Discord Self Bot) first auto join discord selfbot - just with one command join it to your server discord.js-selfbot ?? Requirements Discord

Parsa 25 Dec 12, 2022
OTBot - One-time invite link generator for discord

OTBot ?? Description One-Time Invite Link Generator For Your Discord Server With

Eyyüb 5 Aug 15, 2022
Simple example script that receives the signal from one iptv channel and relays it via websocket to another server to replicate the stream to multiple players

Simple example script that receives the signal from one iptv channel and relays it via websocket to another server to replicate the stream to multiple players

Ericky Thierry 3 Feb 20, 2022
Co-Pilot is a discord Bot designed to be the all-in-one, open-source Discord bot that handles all your server needs.

Welcome to Co-Pilot Bot repo! ?? ?? Co-Pilot (All-in-one Discord Bot) Co-Pilot is a discord Bot designed to be the all-in-one, open-source Discord bot

YMafalha 19 Nov 11, 2022
When new tokens gets listed on a DEX, bots are able to detect this and be one of the first to buy the token for a low price. This is an example of such bot.

Listing Sniping Bot When a new token gets listed on a DEX, bots are able to detect the PairCreated event emitted from the DEX's factory contract. This

MouseLess.eth 15 Dec 21, 2022
One-click embeds for all your links posts, mirrors & comments.

Lens Embeds One-click embeds for all your links posts, mirrors & comments. Getting Started First, install dependencies with yarn install. Then, run th

Miguel Piedrafita 12 Sep 7, 2022
⚡️The Fullstack React Framework — built on Next.js

The Fullstack React Framework "Zero-API" Data Layer — Built on Next.js — Inspired by Ruby on Rails Read the Documentation “Zero-API” data layer lets y

⚡️Blitz 12.5k Jan 4, 2023
It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with buttons. It can play youtube songs, playlists. This bot code was made by Supreme#2401. It uses djs V12

Lofi-Radio-Music-Bot It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with butt

Diwas Atreya 89 Jan 2, 2023
Rule YouTube, Soundcloud and Vimeo player with one API

Polyplayer Polyplayer allows you to rule YouTube's, Soundcloud's and Vimeo's player using one API. Features Playing, pausing, stopping Seek to absolut

Marius 41 Sep 24, 2022
The one DAO to rule them all. A modular DAO written in Clarity for the Stacks blockchain.

ExecutorDAO The one DAO to rule them all. ExecutorDAO is designed to be completely modular and flexible, leveraging Clarity to the fullest extent. The

Marvin 31 Oct 5, 2022
Implementation of Google’s One Version Rule for JS monorepos

@wayfair/one-version One Version to rule them all, One Version to find them, One Version to bring them all, and in the darkness bind them.1 Opinionate

Wayfair Tech 17 Nov 9, 2022
A custom ESLint rule to allow static deps in React Hooks ⚛️

eslint-plugin-react-hooks-static-deps A custom ESLint rule to allow static deps in React Hooks ⚛️ Motivation react-hooks/exhaustive-deps is a really n

Stoïk 3 Apr 5, 2022
This textlint rule found representations not suitable for English papers

This textlint rule found representations not suitable for English papers

SATO Yusuke 4 Mar 1, 2022
This project will be using various AI and Rule Engine algorithm to detect various attack against a company!

?? Introduction This project will be using various AI and Rule Engine algorithm to detect various attack against a website! ?? Mission After starting

Harish S.G 4 Apr 29, 2022
Yet another linter rule to detect compatibility of CSS features.

stylelint-browser-compat Yet another linter rule to detect compatibility of CSS features. This plugin checks if the CSS you're using is supported by t

Masahiro Miyashiro (3846masa) 16 Dec 15, 2022
Validate your Markdown frontmatter data against a JSON schema — remark-lint rule plugin

remark-lint-frontmatter-schema Validate Markdown frontmatter YAML against an associated JSON schema with this remark-lint rule plugin. Supports: Types

Julian Cataldo 20 Dec 10, 2022
Download all Moodle files with one click. This is a Chrome extension built to save time and effort from downloading files manually one by one!

Moodle Downloader Extension Moodle downloader extension for Chrome. The extension is tested with both the TUM moodle and the official moodle demo. Not

Zhongpin Wang 8 Nov 15, 2022
Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!

PostGraphile Instant lightning-fast GraphQL API backed primarily by your PostgreSQL database. Highly customisable and extensible thanks to incredibly

Graphile 11.7k Jan 4, 2023