Discord api java gradle

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

License

MinnDevelopment/java-discord-rpc

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Читайте также:  File05 usr share doc html index html

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

This library is discontinued since the original project discord-rpc is no longer being maintained. Discord now expects you to use the Game SDK which is not open source and will not be wrapped by this project. More information on the deprecation notice can be found here: Deprecation and Migration to Discord GameSDK

This library contains Java bindings for Discord’s official RPC SDK using JNA.

This project provides binaries for linux-x86-64 , win32-x86-64 , win32-x86 , and darwin . The binaries can be found at MinnDevelopment/discord-rpc-release

You can see the official discord documentation in the API Documentation.
Alternatively you may visist the javadoc at jitpack.

In the follwing please replace %VERSION% with the version listed above.

Note: Version 2.0.0 and above will be listed on jcenter, if you are interested in older builds use jitpack.

dependencies < compile 'club.minnced:java-discord-rpc:%VERSION%' >
repository> id>jcenterid> url>https://jcenter.bintray.comurl> name>jcenter-bintrayname> repository>
dependency> groupId>club.minncedgroupId> artifactId>java-discord-rpcartifactId> version>%VERSION%version> dependency>
  1. Install git and JDK 8+
  2. git clone https://github.com/minndevelopment/java-discord-rpc
  3. cd java-discord-rpc
  4. ./gradlew build or on windows gradlew build
  5. Get the jar from build/libs with the name java-discord-rpc-%VERSION%-all.jar

The library can be used just like the SDK. This means you can almost copy the exact code used in the official documentation.

import club.minnced.discord.rpc.*; public class Main < public static void main(String[] args) < DiscordRPC lib = DiscordRPC.INSTANCE; String applicationId = ""; String steamId = ""; DiscordEventHandlers handlers = new DiscordEventHandlers(); handlers.ready = (user) -> System.out.println("Ready!"); lib.Discord_Initialize(applicationId, handlers, true, steamId); DiscordRichPresence presence = new DiscordRichPresence(); presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second presence.details = "Testing RPC"; lib.Discord_UpdatePresence(presence); // in a worker thread new Thread(() -> < while (!Thread.currentThread().isInterrupted()) < lib.Discord_RunCallbacks(); try < Thread.sleep(2000); > catch (InterruptedException ignored) <> > >, "RPC-Callback-Handler").start(); > >

If you want to add an example to the example directory you can do so by making a PR with your package and source. All I ask from you is that the example does not abuse the API in any way and that your example can compile. If you would like to add examples in other JVM languages you must first add support via the build.gradle file.

For example, examples/java/club/minnced/rpc/examples/MyGame.java would be your example file relative to the project root directory.

java-discord-rpc is licensed under the Apache 2.0 License. The base DiscordRPC is licensed under the MIT license.

Find something that is lacking? Fork the project and pull request!

Источник

How To Create A Discord Bot With JDA – Full Beginner Guide

In this tutorial, we will show you how to create a Discord bot using JDA (Java Discord API). With its own slash commands and running as its own CLI program through your Terminal. Discord is one of the most popular communication platforms for gamers, developers and regular people alike. One of the best things about Discord is its open API, which allows developers to build their own bots that can perform various tasks such as moderation, automation, and integration with other services.

Would you like to master Java and become a high paid developer? Click here to get 6-figure coding skills, work from anywhere, create working applications and make an impact on the world with our premiere training program Java Masterclass™ — weekly live coaching calls included!

Prerequisites

Before we start, you need to have the following:

Terminology

  • Application:
    An application is a representation of a single “project” or “product” within the Discord ecosystem. This can refer to a game, bot, integration, or any other type of project that interacts with their API. An application in Discord is typically associated with a unique client ID, which is used to identify the application and authenticate it with the Discord API.
  • Client ID:
    A unique identifier assigned to an application or bot when it is registered with the Discord API. The client ID is used by Discord to identify the application internally or bot when it interacts with the API or users on the platform.
  • Bot Token:
    The password for JDA to connect with the Discord API. Without this token, you are unable to login to your bot and perform actions.
  • Gateway Intent:
    A gateway intent is used by discord to decide what bot is able to access what data exactly. For verified bots (75+ servers and still growing), you have to provide a valid use case for it to gain access to all messages that the bot can recieve.

Step 0: Create a application and make a project

Creating the Discord Application

The first step is to create a new Discord bot application. To do this, follow these steps:

Head on over to the Discord Developer Portal, this is the place where you manage all applications for a bot account. You will need this so Discord knows who owns a bot, a possible privacy policy (if they get verified) and most importantly, so you can get a token to interact with Discord’s API. Once you are in the portal, it should look something like this (If you have not done this before):

Discord Development/Applications Portal

Click on “New Application” and give your application a name, agree with the Developer Terms of Service and Developer Policy:

Once approved, you continue to the dashboard:

In the dashboard, you have control over multiple things, like the “About Me” section of the bot. (All bot become a “user” account. Bots just get some extra endpoints to use, things that user accounts are unable to do). You’ll go to “Bot” on the left.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A Java wrapper for Discord’s OAuth2 API

License

Mokulu/discord-oauth2-api

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A small Discord OAuth2 API wrapper for Java.

  • Generates the authorization URL.
  • Code authorization for access token and refresh token.
  • Refresh the access token with refresh token.
  • Get the user, guilds, and connection info of a user from access token.

Importing To Your Project

  com.github.Mokulu discord-oauth2-api 1.0.2  

Creating the OAuth handler

import io.mokulu.discord.oauth.DiscordOAuth; DiscordOAuth oauthHandler = new DiscordOAuth(clientID: String, clientSecret: String, redirectUri: String, scope: String[]);
String authURL = oauthHandler.getAuthorizationURL(state: String);

state will be ingored by passing null.

import io.mokulu.discord.oauth.model.TokensResponse; TokensResponse tokens = oauthHandler.getTokens(code: String); String accessToken = tokens.getAccessToken(); String refreshToken = tokens.getRefreshToken();

Refreshing the Access Token

TokensResponse tokens = oauthHandler.refreshTokens(refresh_token: String);
import io.mokulu.discord.oauth.DiscordAPI; DiscordAPI api = new DiscordAPI(access_token: String);

The following API fetch calls will throw IOException (HttpStatusException) when access is denied due to invalid scope or expired token.

Scope identity is required. Scope email is required for email and verified values.

import io.mokulu.discord.oauth.model.User; User user = api.fetchUser();
import io.mokulu.discord.oauth.model.Guild; ListGuild> guilds = api.fetchGuilds();

Scope connections is required.

import io.mokulu.discord.oauth.model.Connection; ListConnection> connections = api.fetchConnections();

About

A Java wrapper for Discord’s OAuth2 API

Источник

Оцените статью