tobby48 4 years ago
parent
commit
3d0a326ce5

+ 26
- 18
src/main/java/kr/co/swh/lecture/opensource/project/discode/SendJDA.java View File

20
 
20
 
21
 import com.google.gson.Gson;
21
 import com.google.gson.Gson;
22
 
22
 
23
-import net.dv8tion.jda.api.AccountType;
24
 import net.dv8tion.jda.api.JDA;
23
 import net.dv8tion.jda.api.JDA;
25
 import net.dv8tion.jda.api.JDABuilder;
24
 import net.dv8tion.jda.api.JDABuilder;
26
-import net.dv8tion.jda.api.OnlineStatus;
25
+
27
 
26
 
28
 public class SendJDA {
27
 public class SendJDA {
29
 
28
 
30
-	public static JDA jda;
31
-	public static void main(String[] args) {
29
+	public static void main(String[] args) throws LoginException, InterruptedException {
32
 		// TODO Auto-generated method stub
30
 		// TODO Auto-generated method stub
33
 		List<SentimentalDictionary> dicList = initDatabase();
31
 		List<SentimentalDictionary> dicList = initDatabase();
34
-		JDABuilder jb = new JDABuilder(AccountType.BOT);
35
-		jb.setAutoReconnect(true);
36
-		jb.setStatus(OnlineStatus.DO_NOT_DISTURB);
37
-		jb.setToken("NjYzMjgzODYxMTUyNTk1OTkz.XhGROw.Ps3JJIKlEXoE1eah_5OKHwViThY");
38
-		jb.addEventListeners(new TListener(dicList));
39
-		
40
-		try {
41
-			jda = jb.build();
42
-		} catch (LoginException e) {
43
-			// TODO Auto-generated catch block
44
-			e.printStackTrace();
45
-		}
32
+		// Note: It is important to register your ReadyListener before building
33
+        JDA jda = JDABuilder.createDefault("NjYzMjgzODYxMTUyNTk1OTkz.XhGROw.Ps3JJIKlEXoE1eah_5OKHwViThY")
34
+            .addEventListeners(new TListener(dicList))
35
+            .build();
36
+
37
+        // optionally block until JDA is ready
38
+        jda.awaitReady();
39
+//        
40
+//        이전버전
41
+//		List<SentimentalDictionary> dicList = initDatabase();
42
+//		JDABuilder jb = new JDABuilder(AccountType.BOT);
43
+//		jb.setAutoReconnect(true);
44
+//		jb.setStatus(OnlineStatus.DO_NOT_DISTURB);
45
+//		jb.setToken("NjYzMjgzODYxMTUyNTk1OTkz.XhGROw.Ps3JJIKlEXoE1eah_5OKHwViThY");
46
+//		jb.addEventListeners(new TListener(dicList));
47
+//		
48
+//		try {
49
+//			jda = jb.build();
50
+//		} catch (LoginException e) {
51
+//			// TODO Auto-generated catch block
52
+//			e.printStackTrace();
53
+//		}
46
 	}
54
 	}
47
 
55
 
48
 	public static List<SentimentalDictionary> initDatas() {
56
 	public static List<SentimentalDictionary> initDatas() {
68
 		List<SentimentalDictionary> dicList = new ArrayList<SentimentalDictionary>();
76
 		List<SentimentalDictionary> dicList = new ArrayList<SentimentalDictionary>();
69
 		Connection connection = null;
77
 		Connection connection = null;
70
 		try {
78
 		try {
71
-			Class.forName("com.mysql.jdbc.Driver");
72
-			connection = DriverManager.getConnection("jdbc:mysql://dev-swh.ga:3306/market","root","swhacademy!");
79
+			Class.forName("com.mysql.cj.jdbc.Driver");
80
+			connection = DriverManager.getConnection("jdbc:mysql://183.99.87.90:3306/market?serverTimezone=UTC","root","swhacademy!");
73
 		} catch (SQLException e1) {
81
 		} catch (SQLException e1) {
74
 			// TODO Auto-generated catch block
82
 			// TODO Auto-generated catch block
75
 			e1.printStackTrace();
83
 			e1.printStackTrace();