PattexPattex / ServerGods-2.0.0

A rewrite of ServerGods
MIT License
1 stars 0 forks source link
discord discord-bot java

ServerGods

CodeFactor Release Java License

A not so simple custom discord bot made in Java, designed for my Discord server, but it could be used in other servers with the release of 2.1.0. It has mostly utility features, such as:

The bot is highly configurable, different commands can be enabled/disabled on different servers.

Setup

The bot requires Java 17. I recommend using Eclipse Termuin.

To set up ServerGods for yourself, you must first create a Discord bot on the Discord developer portal. Detailed instructions can be found on the JDA wiki.

Download the latest release from the releases page. Do not download the source code.

After you've downloaded the ServerGods-X.X.X.jar file, copy it over to a directory in which the bot's files won't be deleted.

Next, start the bot, using the command line with a command java -jar ServerGods-X.X.X.jar. The bot should start, create a file config.json and quit. Fill out the config as you want and then restart the bot. If you've done everything correctly, the bot should log something like this:

19:05:04.428 [main] [net.dv8tion.jda.api.JDA] [INFO] - Login Successful!
19:05:04.721 [JDA MainWS-ReadThread] [n.d.j.i.requests.WebSocketClient] [INFO] - Connected to WebSocket
19:05:05.013 [JDA MainWS-ReadThread] [net.dv8tion.jda.api.JDA] [INFO] - Finished Loading!

If an IOException or JSONException is logged upon startup, it should be nothing to be alerted about, since it is normal to be logged if there is no server specific config. An example of the logging event:

01:23:45.678 [main] [c.p.s.c.c.GuildConfigManager] [WARN] - Failed reading from server_config.json (normal if there are no values)

If the bot isn't present in any servers, it will automatically create and log an OAuth2 URL to invite it to a server. After the bot joined a server, move its role to the top in the server's settings.

Config

An example config file can be found here.

How to fill out the config:

Commands

All commands are slash commands/interactions, like /about.

List of slash commands:

There are also two commands enabled for the bot owner only, stop and eval.

Spotify Support

The bot has a built-in support to load & play tracks, playlists and albums directly from Spotify URLs, but it is disabled for default because you need a Spotify app ID & secret to log into the Spotify web API.

Enabling Spotify Support

First, go to the Spotify developers dashboard and log in if you aren't already. Then, create a new app. Fill out the name and description and click create. You should see something like this.

Click on Show client secret to reveal the application's secret. Copy the Client ID and Client Secret to the config. KEEP THE CLIENT SECRET SAFE, DO NOT SHARE IT WITH ANYONE. IF YOU SUSPECT THAT IT HAS BEN SOMEHOW LEAKED, RESET THE SECRET ON THE DASHBOARD.

If you've done everything correctly, the bot will notify you in the log that it has enabled Spotify as an audio source.

If you are still confused, you can go visit Spotify's documentation.

Contributing & Issues

If you have a question or found a bug, please open a new issue and mark it appropriately.

If you wish to make a contribution, open a pull request with a short description about your contribution.

Building... yea, you are on your own, I'm to lazy to write it down.