add support for disabling discord
This commit is contained in:
parent
3d049da565
commit
7dedd82729
5 changed files with 21 additions and 13 deletions
|
@ -45,6 +45,7 @@ public class Configuration {
|
|||
}
|
||||
|
||||
public static class Discord {
|
||||
@Getter public boolean enabled = true;
|
||||
@Getter public String prefix = "default!";
|
||||
@Getter public String token;
|
||||
@Getter public Map<String, String> servers = new HashMap<>();
|
||||
|
|
|
@ -56,18 +56,20 @@ public class Main {
|
|||
|
||||
// idk if these should be here lol, but it is just the discord stuff
|
||||
JDA jda = null;
|
||||
JDABuilder builder = JDABuilder.createDefault(config.discord().token());
|
||||
try {
|
||||
jda = builder.build();
|
||||
jda.awaitReady();
|
||||
} catch (LoginException e) {
|
||||
System.err.println("Failed to login to Discord, stacktrace:");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
} catch (InterruptedException ignored) {
|
||||
System.exit(1);
|
||||
if (config.discord().enabled()) {
|
||||
JDABuilder builder = JDABuilder.createDefault(config.discord().token());
|
||||
try {
|
||||
jda = builder.build();
|
||||
jda.awaitReady();
|
||||
} catch (LoginException e) {
|
||||
System.err.println("Failed to login to Discord, stacktrace:");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
} catch (InterruptedException ignored) {
|
||||
System.exit(1);
|
||||
}
|
||||
jda.getPresence().setPresence(Activity.playing(config.discord().statusMessage()), false); // what does `b` do? kinda sus,..,
|
||||
}
|
||||
jda.getPresence().setPresence(Activity.playing(config.discord().statusMessage()), false); // what does `b` do? kinda sus,..,
|
||||
|
||||
for (Configuration.BotOption botOption : botsOptions) {
|
||||
final Bot bot = new Bot(botOption, bots, config);
|
||||
|
|
|
@ -40,6 +40,8 @@ public class DiscordPlugin {
|
|||
this.servers = options.servers();
|
||||
this.jda = jda;
|
||||
|
||||
if (jda == null) return;
|
||||
|
||||
for (Bot bot : Main.bots) {
|
||||
String channelId = servers.get(bot.host() + ":" + bot.port());
|
||||
|
||||
|
@ -214,6 +216,7 @@ public class DiscordPlugin {
|
|||
}
|
||||
|
||||
public void sendMessageInstantly (String message, String channelId) {
|
||||
if (jda == null) return;
|
||||
final TextChannel logChannel = jda.getTextChannelById(channelId);
|
||||
logChannel.sendMessage(message).queue(
|
||||
(msg) -> doneSendingInLogs.put(channelId, true),
|
||||
|
|
|
@ -166,7 +166,7 @@ public class GrepLogPlugin {
|
|||
.append(Component.newline())
|
||||
.append(Component.text(results.toString()))
|
||||
);
|
||||
} else {
|
||||
} else if (bot.config().discord().enabled()) {
|
||||
bot.chat().tellraw(
|
||||
Component.translatable(
|
||||
"Log query finished, found %s matches. Results were sent in Discord",
|
||||
|
|
|
@ -14,6 +14,7 @@ reconnectDelay: 2000
|
|||
chatQueueDelay: 125
|
||||
|
||||
discord:
|
||||
enabled: true
|
||||
prefix: 'default!'
|
||||
token: 'token here'
|
||||
trustedRoleName: 'Trusted'
|
||||
|
@ -46,6 +47,7 @@ core:
|
|||
refillInterval: 300000 # (60 * 5) * 1000 (5 minutes)
|
||||
# PLEASE give valid JSON component here else the core don't refill at all
|
||||
customName: '[{"text":"ChomeNS ","color":"yellow"},{"text":"Core","color":"green"},{"text":"™","color":"gold"}]'
|
||||
|
||||
selfCare:
|
||||
checkInterval: 450
|
||||
|
||||
|
@ -66,7 +68,7 @@ selfCare:
|
|||
# icu (icontrolUwU)
|
||||
icu:
|
||||
enabled: true
|
||||
positionPacketsPerSecond: 10 # 10 seems to be a best number for me
|
||||
positionPacketsPerSecond: 10 # 10 seems to be the best number for me
|
||||
|
||||
# extras
|
||||
prefix: true
|
||||
|
|
Loading…
Reference in a new issue