geforkt von SteamWar/BungeeCore
Add SteamwarDiscordBot presence
Dieser Commit ist enthalten in:
Ursprung
2c46d2e6a3
Commit
a07c82bc13
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.bot.listeners.RolesInteractionButtonListener;
|
||||
import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
|
||||
@ -27,14 +28,18 @@ import lombok.Getter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.OnlineStatus;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.entities.ActivityFlag;
|
||||
import net.dv8tion.jda.api.entities.RichPresence;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.internal.entities.SelfUserImpl;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class SteamwarDiscordBot {
|
||||
|
||||
@ -50,7 +55,7 @@ public class SteamwarDiscordBot {
|
||||
public SteamwarDiscordBot() {
|
||||
INSTANCE = this;
|
||||
JDABuilder builder = JDABuilder.createDefault(SteamwarDiscordBotConfig.TOKEN);
|
||||
builder.setActivity(new RichPresence() {
|
||||
/*builder.setActivity(new RichPresence() {
|
||||
@Override
|
||||
public long getApplicationIdLong() {
|
||||
return 869611389818400779L;
|
||||
@ -154,7 +159,8 @@ public class SteamwarDiscordBot {
|
||||
public Emoji getEmoji() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
builder.setStatus(OnlineStatus.ONLINE);
|
||||
try {
|
||||
jda = builder.build();
|
||||
@ -166,12 +172,28 @@ public class SteamwarDiscordBot {
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::activity, 30, 0, TimeUnit.SECONDS);
|
||||
DiscordRolesMessage.sendMessage();
|
||||
DiscordRulesMessage.sendMessage();
|
||||
|
||||
new RolesInteractionButtonListener();
|
||||
}
|
||||
|
||||
private int index = 0;
|
||||
|
||||
private void activity() {
|
||||
switch (index) {
|
||||
case 0:
|
||||
jda.getPresence().setActivity(Activity.playing("SteamWar.de"));
|
||||
break;
|
||||
case 1:
|
||||
jda.getPresence().setActivity(Activity.of(Activity.ActivityType.DEFAULT, "Online: " + BungeeCore.get().getProxy().getOnlineCount()));
|
||||
index = 0;
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
public void addListener(ListenerAdapter listenerAdapter) {
|
||||
jda.addEventListener(listenerAdapter);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class DiscordRulesMessage {
|
||||
|
||||
EmbedBuilder builder = new EmbedBuilder();
|
||||
builder.setDescription(SteamwarDiscordBotConfig.RULES_RULES.stream().reduce((s, s2) -> s + "\n" + s2).get());
|
||||
builder.setColor(Color.CYAN);
|
||||
builder.setColor(Color.GRAY);
|
||||
builder.setAuthor("SteamWar", "https://www.steamwar.de");
|
||||
builder.setTitle(SteamwarDiscordBotConfig.RULES_TITLE);
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren