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.*;
|
import java.util.*;
|
||||||
|
|
||||||
// please ignore my ohio code
|
// 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 class DiscordPlugin {
|
||||||
public final JDA jda;
|
public final JDA jda;
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ public class DiscordPlugin {
|
||||||
|
|
||||||
public final String discordUrl;
|
public final String discordUrl;
|
||||||
|
|
||||||
|
private int totalConnects = 0;
|
||||||
|
|
||||||
public boolean shuttedDown = false;
|
public boolean shuttedDown = false;
|
||||||
|
|
||||||
public DiscordPlugin (Configuration config, JDA jda) {
|
public DiscordPlugin (Configuration config, JDA jda) {
|
||||||
|
@ -104,6 +106,15 @@ public class DiscordPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connecting() {
|
public void connecting() {
|
||||||
|
totalConnects++;
|
||||||
|
|
||||||
|
if (totalConnects > 20) return;
|
||||||
|
else if (totalConnects == 20) {
|
||||||
|
sendMessageInstantly("Suspending connecting and disconnect messages from now on", channelId);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sendMessageInstantly(
|
sendMessageInstantly(
|
||||||
String.format(
|
String.format(
|
||||||
"Connecting to: `%s:%s`",
|
"Connecting to: `%s:%s`",
|
||||||
|
@ -116,6 +127,8 @@ public class DiscordPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connected (ConnectedEvent event) {
|
public void connected (ConnectedEvent event) {
|
||||||
|
totalConnects = 0;
|
||||||
|
|
||||||
sendMessageInstantly(
|
sendMessageInstantly(
|
||||||
String.format(
|
String.format(
|
||||||
"Successfully connected to: `%s:%s`",
|
"Successfully connected to: `%s:%s`",
|
||||||
|
@ -128,6 +141,8 @@ public class DiscordPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(DisconnectedEvent event) {
|
public void disconnected(DisconnectedEvent event) {
|
||||||
|
if (totalConnects >= 20) return;
|
||||||
|
|
||||||
final String reason = ComponentUtilities.stringifyAnsi(event.getReason());
|
final String reason = ComponentUtilities.stringifyAnsi(event.getReason());
|
||||||
sendMessageInstantly(
|
sendMessageInstantly(
|
||||||
"Disconnected: \n" +
|
"Disconnected: \n" +
|
||||||
|
|
Loading…
Reference in a new issue