notifier
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
//https://github.com/Javacord/Javacord
|
||||
//https://discordapp.com/developers/applications/
|
||||
//https://docs.javacord.org/api/v/3.0.1/org/javacord/api/DiscordApi.html
|
||||
//https://stackoverflow.com/questions/17654213/how-do-i-create-a-netbeans-style-jar-with-all-dependencies-in-a-lib-folder
|
||||
//ps ax | grep EventNotfierDiscordBot-1.0
|
||||
//kill $pid (number)
|
||||
/*
|
||||
screen -d -m -S nonRoot java -jar /home/sourcemodextensionstest/EventNotfierDiscordBot/EventNotfierDiscordBot-1.0.jar
|
||||
screen -ls (number1)
|
||||
screen -X -S (number1) quit
|
||||
*/
|
||||
|
||||
import DataLayer.DataMapper;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
import org.javacord.api.event.message.MessageCreateEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class Bottest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Insert your bot's token here
|
||||
String token = "NTI5MDIyODgwOTU3MDcxMzk5.Dwqy6w.sgbRejEzZOLdTqyqzDmktSTBDpM";
|
||||
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
||||
api.addMessageCreateListener((MessageCreateEvent event) -> {
|
||||
DataMapper.instance.checkUpdateTime();
|
||||
if (event.getMessageContent().equalsIgnoreCase("!event")) {
|
||||
try {
|
||||
event.getChannel().sendMessage("Event Information: ");
|
||||
DataMapper.instance.initialization();
|
||||
List<StringObject> EventContent = DataMapper.instance.getAllMapValues();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < EventContent.size(); i++) {
|
||||
sb.append(EventContent.get(i).getEventContent()).append("\n");
|
||||
}
|
||||
event.getChannel().sendMessage(sb.toString());
|
||||
} catch (SQLException | IOException | CustomError ex) {
|
||||
Logger.getLogger(Bottest.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package FunctionLayer;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class CustomError extends Exception {
|
||||
|
||||
public CustomError(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package FunctionLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author install1
|
||||
*/
|
||||
public class StringObject {
|
||||
String EventContent;
|
||||
|
||||
public String getEventContent() {
|
||||
return EventContent;
|
||||
}
|
||||
|
||||
public void setEventContent(String EventContent) {
|
||||
this.EventContent = EventContent;
|
||||
}
|
||||
|
||||
public StringObject(String EventContent) {
|
||||
this.EventContent = EventContent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user