Coder Social home page Coder Social logo

atriusx / discord4j Goto Github PK

View Code? Open in Web Editor NEW

This project forked from discord4j/discord4j

0.0 1.0 0.0 18.83 MB

A fast and reactive JVM-based REST/WS wrapper for the official Discord Bot API, written in Java

Home Page: https://discord4j.com

License: GNU Lesser General Public License v3.0

Java 100.00%

discord4j's Introduction

Discord4J

Support Server Invite Maven Central Javadocs CircleCI branch

A fast, reactive Java wrapper for the official Discord Bot API.

Built with Reactor, Netty, and a focus on flexibility, Discord4J provides an effective, non-blocking interface for creating Discord bots. The reactive and asynchronous nature of the library allows for scalability through backpressure handling and the efficient use of resources. Its modularized structure gives the user the ability to tailor their experience to different levels of abstraction and pick the right tools for the job.

Installation

Our current stable line is 3.0.x

Gradle

repositories {
  mavenCentral()
}

dependencies {
  implementation 'com.discord4j:discord4j-core:3.0.9'
}

Maven

<dependencies>
  <dependency>
    <groupId>com.discord4j</groupId>
    <artifactId>discord4j-core</artifactId>
    <version>3.0.9</version>
  </dependency>
</dependencies>

SBT

libraryDependencies ++= Seq(
  "com.discord4j" % "discord4j-core" % "3.0.9"
)

Quick Example (Reactive and Blocking)

final DiscordClient client = new DiscordClientBuilder("token").build();

client.getEventDispatcher().on(ReadyEvent.class)
        .subscribe(ready -> System.out.println("Logged in as " + ready.getSelf().getUsername()));

client.getEventDispatcher().on(MessageCreateEvent.class)
        .map(MessageCreateEvent::getMessage)
        .filter(msg -> msg.getContent().map("!ping"::equals).orElse(false))
        .flatMap(Message::getChannel)
        .flatMap(channel -> channel.createMessage("Pong!"))
        .subscribe();

client.login().block();
final DiscordClient client = new DiscordClientBuilder("token").build();

client.getEventDispatcher().on(ReadyEvent.class)
        .subscribe(ready -> System.out.println("Logged in as " + ready.getSelf().getUsername()));

client.getEventDispatcher().on(MessageCreateEvent.class)
        .subscribe(event -> {
            Message message = event.getMessage();
            if (message.getContent().map("!ping"::equals).orElse(false)) {
                message.getChannel().block().createMessage("Pong!").block();
            }
         });

client.login().block();

Modules

Discord4J is highly oriented towards customizability. To achieve this, the project is divided into several "modules" which can be used separately depending on your use case.

The core module combines the other modules to form high-level abstractions for the entire Discord Bot API. This is the module most users will want when making bots.

The rest module provides a low-level HTTP client specifically for Discord which properly handles Discord's ratelimiting system.

The gateway module provides a low-level WebSocket client for interacting with the Discord Gateway.

The voice module provides a client to manipulate audio through Voice Connections.

The common module contains base utilities and models useful for other modules.

Stores

Discord4J's mechanism for storing information received on the gateway is completely pluggable. This allows both the ability to customize what is stored and how. The Stores repository contains some pre-made implementations as well as the API for making your own.

Useful Links

Development builds

Please follow our instructions at Using Jitpack

v3.1 development builds

Make sure you have the appropriate repositories:

repositories {
  maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
  maven { url 'https://repo.spring.io/snapshot' }
  maven { url 'https://repo.spring.io/milestone' }
  mavenCentral()
}

dependencies {
  implementation 'com.discord4j:discord4j-core:3.1.0-SNAPSHOT'
}

discord4j's People

Contributors

austinv11 avatar quanticc avatar darichey avatar danthonywalker avatar chrislo27 avatar theiglooo avatar grandpanda avatar nerd avatar shadorc avatar xaanit avatar nija123098 avatar d-g-n avatar sizableshrimp avatar phantamanta44 avatar randomname8 avatar doc94 avatar arsenarsen avatar undermybrella avatar kvnxiao avatar grandmind avatar lclc98 avatar robot-rover avatar jamesgallicchio avatar manuelgu avatar techtony96 avatar langerhans avatar kaioru avatar joaaoverona avatar xjade00 avatar curz46 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.