forked from ChomeNS/chomens-bot-java
add connect and disconnect suspending for discord too
This commit is contained in:
parent
bb86bf80c7
commit
e9c510588a
1 changed files with 16 additions and 1 deletions
|
@ -33,7 +33,7 @@ import java.util.List;
|
|||
import java.util.*;
|
||||
|
||||
// please ignore my ohio code
|
||||
// also this is one of the classes which has >100 lines or actually >300 LMAO
|
||||
// also this is one of the classes which has >100 lines or actually >400 LMAO
|
||||
public class DiscordPlugin {
|
||||
public final JDA jda;
|
||||
|
||||
|
@ -45,6 +45,8 @@ public class DiscordPlugin {
|
|||
|
||||
public final String discordUrl;
|
||||
|
||||
private int totalConnects = 0;
|
||||
|
||||
public boolean shuttedDown = false;
|
||||
|
||||
public DiscordPlugin (Configuration config, JDA jda) {
|
||||
|
@ -104,6 +106,15 @@ public class DiscordPlugin {
|
|||
|
||||
@Override
|
||||
public void connecting() {
|
||||
totalConnects++;
|
||||
|
||||
if (totalConnects > 20) return;
|
||||
else if (totalConnects == 20) {
|
||||
sendMessageInstantly("Suspending connecting and disconnect messages from now on", channelId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessageInstantly(
|
||||
String.format(
|
||||
"Connecting to: `%s:%s`",
|
||||
|
@ -116,6 +127,8 @@ public class DiscordPlugin {
|
|||
|
||||
@Override
|
||||
public void connected (ConnectedEvent event) {
|
||||
totalConnects = 0;
|
||||
|
||||
sendMessageInstantly(
|
||||
String.format(
|
||||
"Successfully connected to: `%s:%s`",
|
||||
|
@ -128,6 +141,8 @@ public class DiscordPlugin {
|
|||
|
||||
@Override
|
||||
public void disconnected(DisconnectedEvent event) {
|
||||
if (totalConnects >= 20) return;
|
||||
|
||||
final String reason = ComponentUtilities.stringifyAnsi(event.getReason());
|
||||
sendMessageInstantly(
|
||||
"Disconnected: \n" +
|
||||
|
|
Loading…
Reference in a new issue