46 private static JDA discord =
null;
48 public static void startUp() {
49 System.out.println(
"Initing Discord...");
50 discord = JDABuilder.createDefault(
Constants.TOKEN).build();
52 discord.getPresence().setActivity(Activity.playing(
"Tarnish"));
55 public static JDA getJDA() {
59 public static void sendSimpleMessage(String message) {
60 if (discord ==
null) {
61 System.out.println(
"discord error: discord is null.");
64 discord.getTextChannelById(
Constants.EVENTS_CHANNEL).sendMessage(message).queue();
67 public static void sendBugReport(String playername, String message) {
68 if (discord ==
null) {
69 System.out.println(
"discord error: discord is null.");
72 discord.getTextChannelById(
Constants.BUG_CHANNEL).sendMessage(
"Bug report from " + playername +
": " + message).queue();
74 public static void sendAnnouncement(String message) {
75 if (discord ==
null) {
76 System.out.println(
"discord error: discord is null.");
79 discord.getTextChannelById(
Constants.ANNOUNCEMENT_CHANNEL).sendMessage(message).queue();
82 public static void sendSuggestion(String playername, String message) {
83 if (discord ==
null) {
84 System.out.println(
"discord error: discord is null.");
87 discord.getTextChannelById(
Constants.SUGGESTION_CHANNEL).sendMessage(
"Suggestion from " + playername +
": " + message).queue();
90 public static void sendPunishmentMessage(String staffMember, String action, String playerName, String time) {
91 if (discord ==
null) {
92 System.out.println(
"discord error: discord is null.");
95 Objects.requireNonNull(discord.getTextChannelById(
Constants.PUNISHMENT_CHANNEL))
96 .sendMessage(staffMember +
" has " + action +
" " + playerName +
" " + time).queue();
99 public static void sendEventMessage(String message, String reciever, String icon,
int skillID) {
100 if (discord ==
null) {
101 System.out.println(
"discord error: discord is null.");
105 Objects.requireNonNull(discord.getTextChannelById(
Constants.EVENTS_CHANNEL)).sendMessage((CharSequence)
new EmbedBuilder()
106 .setAuthor(reciever,
"https://harmonyrsps.com",
"https://harmonyrsps.com/files/discord/"+icon+
".png")
107 .setDescription(message)
108 .setThumbnail(
"https://harmonyrsps.com/files/discord/"+skillID+
".png")
112 public static void sendUpdateMessage(String reciever) {
113 if (discord ==
null) {
114 System.out.println(
"discord error: discord is null.");
118 LocalDateTime now = LocalDateTime.now();
119 DateTimeFormatter formatter = DateTimeFormatter.ofPattern(
"MM/dd/yyyy");
120 String formatedDateTime = now.format(formatter);
121 String fileLine =
"";
123 BufferedReader file =
new BufferedReader(
new FileReader(
"source/tools/website_logs/DiscordUpdateLog.txt"));
124 String line = file.readLine();
126 while (line !=
null) {
127 fileLine +=
"> "+line +
"\n";
129 line = file.readLine();
133 }
catch (IOException e) {
136 Objects.requireNonNull(discord.getTextChannelById(
Constants.UPDATE_CHANNEL)).sendMessage((CharSequence)
new EmbedBuilder()
137 .setAuthor(reciever,
"https://harmonyrsps.com",
"https://harmonyrsps.com/assets/images/avatar.png")
138 .setDescription(fileLine)
139 .setThumbnail(
"https://oldschool.runescape.wiki/images/thumb/Ring_of_wealth_scroll_detail.png/1200px-Ring_of_wealth_scroll_detail.png?b1944")
140 .setTitle(
"Update Log - " + formatedDateTime)
144 public static void pollYN(String question) {
145 EmbedBuilder embedBuilder =
new EmbedBuilder();
146 embedBuilder.setTitle(question);
147 embedBuilder.setDescription(
"\uD83D\uDC4D Yes | \uD83D\uDC4E No");
149 discord.getTextChannelById(
Constants.POLL_CHANNEL).sendMessage((CharSequence) embedBuilder.build()).queue(msg->{