File tree 4 files changed +48
-18
lines changed
4 files changed +48
-18
lines changed Original file line number Diff line number Diff line change @@ -11,20 +11,6 @@ repositories {
11
11
12
12
dependencies {
13
13
testCompile group : ' junit' , name : ' junit' , version : ' 4.12'
14
- compile (' net.dv8tion:JDA:VERSION' ) {
15
- exclude module : ' opus-java'
16
- }
17
- }
18
- version ' 1.0-SNAPSHOT'
19
-
20
- apply plugin : ' java'
21
-
22
- sourceCompatibility = 1.8
23
-
24
- repositories {
25
- mavenCentral()
14
+ compile ' net.dv8tion:JDA:3.8.1_454'
26
15
}
27
16
28
- dependencies {
29
- testCompile group : ' junit' , name : ' junit' , version : ' 4.12'
30
- }
Original file line number Diff line number Diff line change 1
1
rootProject. name = ' Lupus590.C4Bot'
2
- rootProject. name = ' Lupus590.C4Bot'
3
2
Original file line number Diff line number Diff line change
1
+ import net .dv8tion .jda .client .entities .Group ;
2
+ import net .dv8tion .jda .core .JDA ;
3
+ import net .dv8tion .jda .core .JDABuilder ;
4
+ import net .dv8tion .jda .core .Permission ;
5
+ import net .dv8tion .jda .core .entities .*;
6
+ import net .dv8tion .jda .core .events .message .MessageReceivedEvent ;
7
+ import net .dv8tion .jda .core .exceptions .PermissionException ;
8
+ import net .dv8tion .jda .core .exceptions .RateLimitedException ;
9
+ import net .dv8tion .jda .core .hooks .ListenerAdapter ;
10
+
11
+ public class MessageListener extends ListenerAdapter
12
+ {
13
+ @ Override
14
+ public void onMessageReceived (MessageReceivedEvent event )
15
+ {
16
+ if (event .getAuthor ().isBot ()) return ;
17
+ // We don't want to respond to other bot accounts, including ourself
18
+ Message message = event .getMessage ();
19
+ String content = message .getContentRaw ();
20
+ // getContentRaw() is an atomic getter
21
+ // getContentDisplay() is a lazy getter which modifies the content for e.g. console view (strip discord formatting)
22
+ if (content .equals ("!ping" ))
23
+ {
24
+ MessageChannel channel = event .getChannel ();
25
+ channel .sendMessage ("Pong!" ).queue (); // Important to call .queue() on the RestAction returned by sendMessage(...)
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ import net .dv8tion .jda .client .entities .Group ;
2
+ import net .dv8tion .jda .core .JDA ;
3
+ import net .dv8tion .jda .core .JDABuilder ;
4
+ import net .dv8tion .jda .core .Permission ;
5
+ import net .dv8tion .jda .core .entities .*;
6
+ import net .dv8tion .jda .core .events .message .MessageReceivedEvent ;
7
+ import net .dv8tion .jda .core .exceptions .PermissionException ;
8
+ import net .dv8tion .jda .core .exceptions .RateLimitedException ;
9
+ import net .dv8tion .jda .core .hooks .ListenerAdapter ;
10
+
1
11
public class main {
2
- public static void main (String [] args )
12
+ public static void main (String [] args ) throws Exception
3
13
{
4
- System .out .println ("hello world" );
14
+ if (args [0 ].isEmpty ()) {
15
+ System .out .println ("Please run again passing in a bot token" );
16
+ return ;
17
+ }
18
+
19
+ System .out .println ("Using Discord bot token: " +args [0 ]);
20
+ JDA jda = new JDABuilder (args [0 ]).build ();
21
+ jda .addEventListener (new MessageListener ());
5
22
}
6
23
}
You can’t perform that action at this time.
0 commit comments