Giter Site home page Giter Site logo

joshix-1 / javacord Goto Github PK

View Code? Open in Web Editor NEW

This project forked from javacord/javacord

0.0 1.0 2.0 7.17 MB

An easy to use multithreaded library for creating Discord bots in Java.

Home Page: https://discord.gg/0qJ2jjyneLEgG7y3

License: Apache License 2.0

Java 94.85% Groovy 5.15%

javacord's Introduction

Javacord Latest version Latest JavaDocs Javacord Wiki Javacord Discord server

An easy to use multithreaded library for creating Discord bots in Java.

Feature Coverage

Javacord supports every action a Discord bot is able to perform.
Some of these features include, but are not limited to:

  • sending messages
  • attaching files
  • event listening
  • user management
  • server administration
  • ... and many others

Sending voice will be added in an upcoming release.
New features introduced by Discord are typically added in less than one week, depending on scale.

Download / Installation

The recommended way to get Javacord is to use a build manager, like Gradle or Maven.
If you are not familiar with build managers, you can follow this Setup Guide or download Javacord directly from GitHub.

Javacord Dependency

Gradle

repositories { mavenCentral() }
dependencies { implementation 'org.javacord:javacord:3.0.5' }

Maven

<dependency>
    <groupId>org.javacord</groupId>
    <artifactId>javacord</artifactId>
    <version>3.0.5</version>
    <type>pom</type>
</dependency>

Optional Logger Dependency

Any Log4j-2-compatible logging framework can be used to provide a more sophisticated logging experience with being able to configure log format, log targets (console, file, database, Discord direct message, ...), log levels per class, and much more.

For example, Log4j Core in Gradle

dependencies { runtimeOnly 'org.apache.logging.log4j:log4j-core:2.11.0' }

Take a look at the Logger Configuration wiki article for further information.

IDE Setup

If you have never used Gradle or Maven before, you should take a look at one of the setup tutorials:

Support

Javacord's Discord community is an excellent resource if you have questions about the library.

Documentation

  • The Javacord Wiki is a great place to get started
  • Additional documentation can be found in the JavaDoc

Logging in

Logging in is very simple

public class MyFirstBot {

    public static void main(String[] args) {
        // Insert your bot's token here
        String token = "your token";

        DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();

        // Add a listener which answers with "Pong!" if someone writes "!ping"
        api.addMessageCreateListener(event -> {
            if (event.getMessageContent().equalsIgnoreCase("!ping")) {
                event.getChannel().sendMessage("Pong!");
            }
        });

        // Print the invite url of your bot
        System.out.println("You can invite the bot by using the following url: " + api.createBotInvite());
    }

}

You can also login non-blocking asynchronously

public class MyFirstBot {

    public static void main(String[] args) {
        // Insert your bot's token here
        String token = "your token";

        new DiscordApiBuilder().setToken(token).login().thenAccept(api -> {
                    // Add a listener which answers with "Pong!" if someone writes "!ping"
                    api.addMessageCreateListener(event -> {
                        if (event.getMessageContent().equalsIgnoreCase("!ping")) {
                            event.getChannel().sendMessage("Pong!");
                        }
                    });

                    // Print the invite url of your bot
                    System.out.println("You can invite the bot by using the following url: " + api.createBotInvite());
                })
                // Log any exceptions that happened
                .exceptionally(ExceptionLogger.get());
    }

}

Check out the Example Bot to learn more.

How to create a bot user and get its token

Version numbers

The version number has a 3-digit format: major.minor.trivial

  • major: Increased extremely rarely to mark a major release (usually a rewrite affecting very huge parts of the library). You can expect this digit to not change for several years.
  • minor: Any backwards incompatible change to the api. You can expect this digit to change about 1-3 times per year.
  • trivial: A backwards compatible change to the api. This is usually an important bugfix (or a bunch of smaller ones) or a backwards compatible feature addition. You can expect this digit to change 1-2 times per month.

Deprecation policy

A method or class that is marked as deprecated can be removed with the next minor release (but it will usually stay for several minor releases). A minor release might remove a class or method without having it deprecated, but we will do our best to deprecate it before removing it. We are unable to guarantee this though, because we might have to remove / replace something due to changes made by Discord, which we are unable to control. Usually you can expect a deprecated method or class to stay for at least 6 months before it finally gets removed, but this is not guaranteed.

Discord Server

Join the Javacord Server for support, status updates, or just chatting with other users.

javacord's People

Contributors

ajmeese7 avatar bassner avatar bastian avatar boneyisspooky avatar bourne-id avatar burdoto avatar comroid-commit avatar donotspampls avatar gamingandstuffs avatar iamanonymous8 avatar iblitzkriegi avatar itsjh avatar javacord-ci avatar kenwiel avatar l0stillusion avatar moudoux avatar mysterypotatoguy avatar nguyenquyhy avatar saladoc avatar shawishi avatar that1guy232 avatar thediamondpicks avatar theglitch76 avatar vampire avatar yrsegal avatar

Watchers

 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.