Skip to content

A Discord Bot written in TypeScript using Sapphire, discord.js, Next.js and React

Notifications You must be signed in to change notification settings

iamjethrooo/botlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Botlog

A Discord Bot written in TypeScript using Sapphire, discord.js, Next.js and React

image image

System dependencies

Setup bot

PostgreSQL

Linux

Either from the official site or follow the tutorial for your distro.

MacOS

Get brew, then enter 'brew install postgresql'.

Windows

Download from here

Redis

MacOS

brew install redis.

Windows

Download from here.

Linux

Follow the instructions here.

Settings (env)

Create a .env file in the root directory and copy the contents of .env.example to it. Note: if you are not hosting postgres on Heroku you do not need the SHADOW_DB_URL variable.

# DB URL
DATABASE_URL="postgresql://john:doe@localhost:5432/botlog?schema=public"
SHADOW_DB_URL="postgresql://john:doe@localhost:5432/botlog?schema=public"

GUILD_ID=

# ECONOMY
COIN_NAME=""
COIN_EMOJI=""
RED_COLOR="F5463D"
GREEN_COLOR="3DF556"

CASH_PER_CHAT=1
MIN_CASH_PER_CHAT=5
MAX_CASH_PER_CHAT=12
STARTING_CASH=200
INTERVAL=60

SNIPE_COST=200
SINGLE_SNIPE_COST=100

ROB_CHANCE=0.x
ROB_CHANCE_THIEF=0.x
ROB_CHANCE_MOD=0.x

ROB_RATE=0.x
ROB_RATE_THIEF=0.x

ROB_COOLDOWN=
ROB_COOLDOWN_THIEF=1

ROLE_ID_THIEF=
ROLE_ID_INMATE=

HEIST_WAITING_TIME=
HEIST_JAIL_TIME=
HEIST_REDUCED_JAIL_TIME=

HEIST_BASE_CHANCE=0.x
HEIST_ADDITIONAL_CHANCE=0.x

HEIST_BASE_RATE=0.x
HEIST_ADDITIONAL_RATE=0.x

HEIST_MAX_MEMBERS=5
HEIST_COOLDOWN=604800

COINFLIP_COOLDOWN=600

# Bot Token
# DISCORD_TOKEN=""
DISCORD_TOKEN=""
CAT_API=""
DOG_API=""
CLIENT_ID=""
CLIENT_SECRET=""
PREFIX=""
RAWG_API=""
TENOR_API=""
WEATHER_API=""
YOUTUBE_API=""

# Next Auth
NEXTAUTH_SECRET="somesupersecrettwelvelengthword"
NEXTAUTH_URL=http://domain:3000
NEXTAUTH_URL_INTERNAL=http://localhost:3000
NEXT_PUBLIC_INVITE_URL="https://discord.com/api/oauth2/authorize?client_id=yourclientid&permissions=8&scope=bot"

# Next Auth Discord Provider
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""

# Spotify
SPOTIFY_CLIENT_ID=""
SPOTIFY_CLIENT_SECRET=""

# Lavalink
LAVA_HOST=""
LAVA_PASS=""
LAVA_PORT=
LAVA_SECURE=

# Redis
REDIS_HOST="127.0.0.1"
REDIS_PORT=6379
REDIS_PASSWORD=""
REDIS_DB=1

# ChatGPT
SESSION_TOKEN=""

Gif features

If you have no use in the gif commands, leave everything under 'Other APIs' empty. Same applies for Twitch, everything else is needed.

DB URL

Change 'john' to your pc username and 'doe' to some password, or set the name and password you created when you installed Postgres.

Bot Token

Generate a token in your Discord developer portal.

Next Auth

You can leave everything as is, just change 'yourclientid' in NEXT_PUBLIC_INVITE_URL to your Discord bot id and then change 'domain' in NEXTAUTH_URL to your domain or public ip. You can find your public ip by going to www.whatismyip.com.

Next Auth Discord Provider

Go to the OAuth2 tab in the developer portal, copy the Client ID to DISCORD_CLIENT_ID and generate a secret to place in DISCORD_CLIENT_SECRET. Also, set the following URLs under 'Redirects':

Make sure to change 'domain' in http://domain:3000/api/auth/callback/discord to your domain or public ip.

Spotify and Twitch

Create an application in each platform's developer portal and paste the relevant values.

Running the bot

  1. If you followed everything right, hit npm i in the root folder. When it finishes make sure prisma didn't error.
  2. Wait a few seconds and hit npm run dev.
  3. If everything works, your bot and dashboard should be running.
  4. Enjoy!

Resources

Getting a Tenor API key

Getting a NewsAPI API key

Getting a Genius API key

Getting a rawg API key

Getting a Twitch API key

Installing Node.js on Debian

Installing Node.js on Windows

Installing on a Raspberry Pi

Using a Repl.it LavaLink server

Using a public LavaLink server

Using an Internal LavaLink server

Contributing

Fork it and submit a pull request! Anyone is welcome to suggest new features and improve code quality!

About

A Discord Bot written in TypeScript using Sapphire, discord.js, Next.js and React

Topics

Resources

Stars

Watchers

Forks

Languages