Skip to content

Mauzy0x00/Discord-Bot

Repository files navigation

Discord Bot

This repository contains a simple Discord bot that I created as a learning endeavor. The bot has limited commands and is designed to run on my home web server.

Getting Started

To use this bot, you will need to do the following:

  1. Clone this repository to your local machine.
  2. If you do not have nodejs you will need to install it. One method of installation on a windows machine: winget install OpenJS.NodeJS NOTE: Installing node via apt may result in installing an old version of node that is incompatible. Please ensure you have the correct verison of node if you have errors on the next steps.

    You must change versions of node

    • By default, apt will install an old version of npm and therefore installs and old version of discordjs which does not have support for slash commands.
    • You can use nvm to manage versions of node and npm. Doing so is outside of the scope of this tutorial.
    • Node version must be v20.4.0 or greater. Npm version must be v9.7.2 or greater. Changing the version in package.json and using node install looks like it might work too (I have no idea what I am doing)
  3. Install the necessary dependencies by running sudo apt install nodejs, npm install discord.js, npm install openai, npm install axios.
  4. Set up a Discord bot through the Discord developer portal and obtain a bot token. (Review Discord documentation if needed)
  5. Create an account at OpenAI and obtain an API key.
  6. Create an account at Tenor and obtain an API key.
  7. Create a config.json file in the root directory of the project and add the following:

{ "clientId": "Bot ID", "guildId": "your discord server ID", "token": "your bot token", "tenorAPI": "your tenor api token", "OpenAIApiKey": "your openai api token" }

  1. Test your build by running node deploy-commands.js in the root directory of the project.
  2. Run the bot by running node index.js. If you want the process to run in the background without exiting use nohup node discord-bot/index.js &.

Starting the bot via SSH

  1. Install tmux on your server sudo apt install tmux.
  2. Start tmux by typing tmux. Note: If you get an error here, ensure you are using the same command-line interpreter as your server. In otherwords, if you are using kitty and zsh, but your server is using bash, tmux will fail. Be sure to use bash.
  3. Start the bot in the tmux session nohup node discord-bot/index.js &.
  4. Leave and detatch by typing Ctrl+b then press d. You can now leave your remote session and the process will continue running.

Available Commands

Currently, the bot supports the following commands:

Admin Commands

  • /message-logs: Show and configure information about deleted messages.
  • /reaction-role: Manages reaction roles.
  • /role-create: Creates a role.
  • /send-message: Sends a message .
  • /avatar: Fetches a user's avatar.
  • /bing: Replies with "Bong!".
  • /prune: Prune specified number of messages in the active channel.
  • /server: Fetch server information.
  • /user: Fetch user information.
  • /poll: Creates a poll.
  • /setjoinchannel: Select a channel and message for join notifications.

Emotes

  • /blush: Sends a blush emote.

ChatGPT API Bots

  • /AlbertCamus: Engages in a conversation with Albert Camus.
  • /BFSkinner: Engages in a conversation with BF Skinner.
  • /ChatGPT: Engages in a conversation with ChatGPT.
  • /DocChat: Engages in a conversation with Dr Disrespect.
  • /DonaldTrump: Engages in a conversation with Donald Trump.
  • /DreamChat: Engages in a conversation with Carl Jung prompted to interpret dreams.
  • /FurryChat: Engages in a conversation with a furry.
  • /CarlinChat: Engages in a conversation with George Carlin.
  • /BidenChat: Engages in a conversation with Joe Biden.
  • /JoeChat: Engages in a conversation with Joe Rogan.
  • /MarcusAurelius: Engages in a conversation with Marcus Aurelius.
  • /OrcChat: Engages in a conversation with an orc.
  • /RustChat: Engages in a conversation with a Rust developer.
  • /SteveIrwin: Engages in a conversation with Steve Irwin.

Social Gif Emotes

  • /bite: Bites someone.
  • /bully: Bullies someone.
  • /cuddle: Cuddles with someone.
  • /greet: Greets someone.
  • /handholding: Holds hands with someone.
  • /highfive: Gives a high-five.
  • /hold: Holds someone.
  • /hug: Hugs someone.
  • /kill: Kills someone.
  • /kiss: Kisses someone.
  • /lick: Licks someone.
  • /nom: Noms on someone.
  • /pat: Pats someone.
  • /poke: Pokes someone.
  • /punch: Punches someone.
  • /slap: Slaps someone.
  • /snuggle: Snuggles with someone.
  • /stare: Stares at someone.
  • /tickle: Ticks someone.
  • /wave: Waves at someone.

Contributing

Just make a pull request!

AI Disclaimer

Portions of this code have been generated by a large language model. Though it has been edited and reviewed by me, I feel obligated to include a disclaimer noting its use in this project.

About

Resources

Stars

Watchers

Forks

Packages

No packages published