[[분류:Discord]][[분류:프로그래밍]] [include(틀:Discord)] ||||<:><tablealign=right><#742DC4><tablebordercolor=#742DC4>{{{+4 {{{#ffffff Java Discord API}}} }}}|||| ||<#742DC4> {{{#ffffff 최신 버전}}} || 4.2.0_228[* 2021-2-19 기준]|| ||||<:>[[https://github.com/DV8FromTheWorld/JDA/|[[파일:github-logo.png|width=23]]]],[[https://discord.com/invite/0hMr4ce0tIl3SLv5|[[파일:디스코드 아이콘.png|width=23]]]], [[https://ci.dv8tion.net/job/JDA/javadoc/|Javadoc]]|||| [목차] == 개요 == Discord API를 자바에서 간편하게 쓸 수 있는 비공식 라이브러리다. 자바 비공식 라이브러리들중에 JDA 라이브러리가 가장 인기가 많다. == 설치 == VERSION를 버전으로 바꿔 적으면 된다. * [[https://github.com/DV8FromTheWorld/JDA/wiki/2%29-Eclipse-Setup|이클립스 설정]] === [[Maven]] === {{{ <dependency> <groupId>net.dv8tion</groupId> <artifactId>JDA</artifactId> <version>VERSION</version> </dependency> }}} {{{ <repository> <id>jcenter</id> <name>jcenter-bintray</name> <url>https://jcenter.bintray.com</url> </repository> }}} 오디오 모듈없이 설치 {{{ <dependency> <groupId>net.dv8tion</groupId> <artifactId>JDA</artifactId> <version>VERSION</version> <exclusions> <exclusion> <groupId>club.minnced</groupId> <artifactId>opus-java</artifactId> </exclusion> </exclusions> </dependency> }}} === Gradle === {{{ dependencies { compile 'net.dv8tion:JDA:VERSION' } repositories { jcenter() } }}} 오디오 모듈없이 설치 {{{ dependencies { compile ('net.dv8tion:JDA:VERSION') { exclude module: 'opus-java' } } }}} == 예제 == 간단한 예제들이다. > 예제를 작성할 때 가능하면 최신버전기준으로 해주십시오. === Ping Bot === {{{#!syntax java public class NamuWikiBot extends ListenerAdapter { public static void main(String[] args) throws LoginException { // 기본 jda를 만들고 JDA jda = JDABuilder.createDefault("토큰").build(); // jda에 이벤트를 감지하는 리스너를 넣는다. jda.addEventListener(new NamuWikiBot()); } @Override public void onMessageReceived(MessageReceivedEvent event) { // 받은 메세지 내용이 ping이라면 if (event.getMessage().getContentRaw().equals("!ping")) { // pong라는 내용을 보낸다. event.getChannel().sendMessage("pong!").queue(); } } } }}}