Java library allowing for quick development of Discord bots

Overview

Discord-Bot-Library

Java library that acts as an abstraction of Discord4J, allowing for quick development of Discord bots

The goal for this project was to greatly simplify the development process of basic and intermidiate level Discord bots using Discord4J, as this is currently a somewhat cumbersome process, requiring you to set up systems for commands, interactions, etc. yourself before you can actually start development. This library takes care of most of that setup in the background, leaving you to do the actual development of the bot. Please refer to the Discord4J docs if you if you are unsure about a Discord4J feature.

It should be sufficient for the most common usecases. For more advanced projects however, the main Discord4J api would be a better choice, as you are more directly communicating with Discord, and this library leaves out a lot of systems present in Discord4J.

please note: it is highly recommended to have some experience with Discord4J when using this library

Features of the libary

  • Managing classic chat-based commands

  • Full support for Message-, Slash- and Usercommands

  • Easy to use system for buttons and select menus

  • A custom console window to output bot information to

  • Classes for easily reading and writing to and from Json files

  • Easily updating the presence of the Discord bot

Contributing

If you want to contribute to the project, simply leave an issue or pull request, and I'll take a look at it.

Using the library

<dependencies>
  <dependency>
    <groupId>io.github.MichaPehlivan</groupId>
    <artifactId>botlibrary</artifactId>
    <version>1.3</version>
  </dependency>
</dependencies>

Tutorial

When using the library, start by creating a DiscordBot object:

DiscordBot bot = new DiscordBot("token");

Here "token" is the token of your Discord bot, which you can get through the Discord developer portal. You can put this in the main loop of your code, and end the loop with bot.getGateway().onDisconnect().block(); to keep the bot running until you close the program.

From here you can set the bot's command prefix with:

bot.setPrefix("prefix");

And the bots presence with:

bot.status().online().playing("playing status")

The library supports the online, offline, idle, donotdisturb, invisible and unknown status, and the playing, listening, streaming, watching and competing activities.

To add a classic chat based command, you can use the addCommand(String name, Command command) method. Here name is the name of the command, which you will use to call the command in Discord, and command either a class or a lambda statement implementing the Command interface. For example:

bot.addCommand("ping", event -> 
  event.getMessage().getChannel().block().createMessage("Pong!").then());

This adds a command that responds with "Pong!" to any message starting with your prefix and "ping".

Interactions

The library fully supports application commands(Message, Slash and User commands), and components(Buttons and Select menus). To use any interaction, you need to implement the appropriate class. These classes are MessageCommand, SlashCommand, UserCommand, DiscordButton and DiscordSelectMenu.

An application command can be added to all Discord servers by using:

bot.getApplicationCommandManager().addGlobalMessageCommand(new MessageCommandExample());

Where MessageCommandExample is a class implementing the MessageCommand interface.

You can also add a command to a specific Discord server by using:

bot.getApplicationCommandManager().addGuildMessageCommand(new MessageCommandExample(), 699536873778780392L);

Where the long is the id of the Discord server you want to add the command to.

Using Buttons and Select menus is even easyer. You can simply use a MessageCreateSpec and attach the component to it:

MessageCreateSpec.builder()
  .addComponent(ActionRow.of(new ExampleButton().getButton()))
  .build();

Where ExampleButton is a class implementing the DiscordButton interface.

An example bot can be found in the test folder, and more detailed information on classes and methods can be found in the javadoc.

You might also like...

An open source Discord Bot made in Java!

An open source Discord Bot made in Java!

ShiShi An open source Java Discord bot Report Bug . Request Feature About The Project This is a open source Java discord bot making use of the JDA lib

Aug 5, 2022

This is some Discord bot I made to help me learn Java. Not very useful yet.

JennyChan This is some Discord bot I made to help me learn Java. Not very useful yet. What it can do so far: Reply to mention List commands Show bot u

Sep 1, 2022

A Java Discord Bot Base that supports Slash Commands!

Nyjava Nyjava is a discord bot base that supports 🎉 Discord Slash Commands! 🎉 I'll see where I go with this, I might update it, I might not. Time wi

Nov 19, 2022

NeoBotCore is an extensible Discord Bot created using Java.

NeoBotCore A NeoBotCore is an implementation of the NeoBotAPI. NeoBot is an extensible Discord Bot developed using Java. By combining modules, you can

Jun 22, 2022

A lightweight messaging library that simplifies the development and usage of RabbitMQ with the AMQP protocol.

kryo-messaging This library contains a simple MessagingService which simplifies the setup and work with RabbitMQ and the AMQP protocol. Usage Gradle r

Jan 10, 2022

Experimental Discord Mobile Rich Presence (Android)

MRPC Experimental Discord Mobile Rich Presence (Android) How does it work? It's pretty simple. Connect to the Discord Gateway as a normal Discord Clie

Dec 25, 2022

Shitty, yet simple way to get someone's token right at their discord client's startup.

discord-token-stealer Shitty, yet simple discord injector to add a little spice to their discord client Disclaimer: This is for educational purposes o

Sep 26, 2022

Twiscord es una simple aplicación que permite conectar Twitter y Discord para poder publicar cosas en ambas plataformas a la vez.

Twiscord Twiscord es una simple aplicación que permite conectar Twitter y Discord para poder publicar en ambas plataformas a la vez dedicado a streame

Jan 10, 2022

Velocity global chat/discord bridge

VelocityDiscord Velocity global chat/discord bridge Default config generated on startup: # Don't change this config_version="1" [discord] # Bot token

Dec 18, 2022
Releases(1.3)
Owner
null
Aliucord - Discord Android app mod inspired by desktop Discord client mods.

Aliucord Aliucord is a modification for the Android Discord app inspired by desktop client modifications. Unlike other Android Discord app modificatio

null 2k Dec 31, 2022
CVE-2021-44228 - Apache log4j RCE quick test

Build ./build.sh Start log4j RCE Server ./start-log4j-rce-server.sh Test Run java -cp log4j-rce-1.0-SNAPSHOT-all.jar log4j Check if you get logs in ha

Jeffrey Li 3 Feb 1, 2022
This app is simple and awesome notepad. It is a quick notepad editing experience when writing notes,emails,message,shoppings and to do list.

This app is simple and awesome notepad. It is a quick notepad editing experience when writing notes,emails,message,shoppings and to do list.It is easy to use and enjoy hassle free with pen and paper.

Md Arif Hossain 1 Jan 18, 2022
Doing red/green/refactor with quick and visual feedback loop on your Nanoleaf

nanoleaf-intellij-plugin Want fancy coloured and visual quick feedback for your tests? Install the Nanoleaf IntelliJ plugin. The plugin listen to your

Baptiste Lecocq 5 Dec 27, 2022
Parallel programming quick sort and parallel sum examples with Fork-join, RecursiveTask, RecursiveAction

QuickSortMultiThreading Parallel programming quick sort and parallel sum examples with Fork-join, RecursiveTask<T>, RecursiveAction Fork-Join Fork-Joi

Güven TUNCAY 4 Jun 12, 2022
A networking library for LibGDX utilizing Netty allowing easy creation of multiplayer games.

Lunar What is Lunar? Lunar is a networking library for LibGDX. With lunar you can easily create multiplayer games quickly and efficiently. Lunar provi

Vrekt 28 Nov 25, 2022
Pandora - allowing to control different agents (Windows & Linux machine) from server(s) and master

Pandora Pandora is now an open-source project allowing to control different agents (Windows & Linux machine) from server(s) and master. Features Auto-

nz 75 Dec 22, 2022
Nrich is a Java library developed at CROZ whose purpose is to make development of applications on JVM a little easier.

nrich Nrich is a Java library developed at CROZ whose purpose is to make development of applications on JVM a little easier. It contains modules that

CROZ 44 Nov 12, 2022
Tzatziki - Decathlon library to ease and promote Test Driven Development of Java microservices!

Tzatziki Steps Library This project is a collection of ready-to-use Cucumber steps making it easy to TDD Java microservices by focusing on an outside-

Decathlon 32 Dec 15, 2022
Application for creating blog posts, developed with Java using Spring Framework for backend and Angular along with PrimeNG Library for frontend development.

Application for creating blog posts, developed with Java using Spring Framework for backend and Angular along with PrimeNG Library for frontend development.

Áureo Carmelino 10 Nov 27, 2022