Skip to content

Commit 8a0a42e

Browse files
authored
Bot | v1.0
- Added to edit the type of activity (Playing, Competing, etc.).
1 parent 81ea476 commit 8a0a42e

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>club.lite.bot</groupId>
88
<artifactId>Bot</artifactId>
9-
<version>1.0</version>
9+
<version>1.1</version>
1010
<url>https://dsc.gg/liteclubdevelopment</url>
1111

1212
<properties>

src/main/java/club/lite/bot/Bot.java

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.google.gson.Gson;
55
import com.google.gson.GsonBuilder;
66

7-
import java.io.File;
87
import java.util.Random;
98
import java.util.concurrent.ThreadLocalRandom;
109

@@ -49,28 +48,57 @@ public void onEnable() {
4948
if (!this.getDescription().getName().equals("Bot")
5049
|| !this.getDescription().getWebsite().equals("https://dsc.gg/liteclubdevelopment")
5150
|| !this.getDescription().getDescription().equals("Simple Discord Bot Status Plugin")
52-
|| !this.getDescription().getVersion().equals("1.0")
51+
|| !this.getDescription().getVersion().equals("1.1")
5352
|| !this.getDescription().getAuthors().contains("HCFAlerts")) {
5453
Bukkit.getServer().getPluginManager().disablePlugin(this);
5554
for (int i = 0; i < 100; i++) {
5655
Bukkit.getServer().getConsoleSender().sendMessage(CC.t("&cWhy are you changing the plugin.yml?"));
5756
}
5857
return;
59-
}
58+
}
59+
60+
this.loaded = true;
61+
FileConfig configConfig = new FileConfig(this, "config.yml");
62+
Gson gson = (new GsonBuilder()).setPrettyPrinting().create();
63+
Logger.state("Enabled");
6064

61-
this.loaded = true;
62-
FileConfig configConfig = new FileConfig(this, "config.yml");
63-
Gson gson = (new GsonBuilder()).setPrettyPrinting().create();
64-
Logger.state("Enabled");
65-
String discordToken = (Bot.getInstance().getConfig().getString("TOKEN"));
66-
this.discordBot = JDABuilder.createDefault(discordToken).setStatus(OnlineStatus.valueOf(Bot.getInstance().getConfig().getString("ACTIVITY.STATUS")))
67-
// -> - > -> -> -> -> PLAYING, COMPETING, WATCHING, LISTENING, STREAMING
68-
.setActivity(Activity.competing(Bot.getInstance().getConfig().getString("ACTIVITY.ACTIVITY")))
69-
.enableIntents(GatewayIntent.GUILD_MEMBERS, new GatewayIntent[0]).build();
65+
String discordToken = Bot.getInstance().getConfig().getString("TOKEN");
66+
String activityType = Bot.getInstance().getConfig().getString("ACTIVITY.TYPE").toUpperCase();
67+
String activityText = Bot.getInstance().getConfig().getString("ACTIVITY.ACTIVITY");
68+
String streamUrl= Bot.getInstance().getConfig().getString("ACTIVITY.STREAM_URL", "https://twitch.tv/liteclubdevelopment");
69+
OnlineStatus status = OnlineStatus.valueOf(Bot.getInstance().getConfig().getString("ACTIVITY.STATUS").toUpperCase());
70+
71+
Activity activity;
72+
switch (activityType) {
73+
case "PLAYING":
74+
activity = Activity.playing(activityText);
75+
break;
76+
case "WATCHING":
77+
activity = Activity.watching(activityText);
78+
break;
79+
case "LISTENING":
80+
activity = Activity.listening(activityText);
81+
break;
82+
case "STREAMING":
83+
activity = Activity.streaming(activityText, streamUrl);
84+
break;
85+
case "COMPETING":
86+
activity = Activity.competing(activityText);
87+
break;
88+
default:
89+
activity = Activity.playing(activityText);
90+
break;
7091
}
7192

93+
this.discordBot = JDABuilder.createDefault(discordToken)
94+
.setStatus(status)
95+
.setActivity(activity)
96+
.enableIntents(GatewayIntent.GUILD_MEMBERS, new GatewayIntent[0])
97+
.build();
98+
}
99+
72100
@Override
73101
public void onDisable() {
74-
Logger.state("Disabled");
102+
Logger.state("Disabled");
75103
}
76104
}

src/main/resources/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ TOKEN: "INSERT-YOUR-DISCORD-BOT-TOKEN-HERE" # GET YOUR BOT TOKEN IN/OBTENGA EL T
55
ACTIVITY:
66
TYPE: "PLAYING" # PLAYING (JUGANDO a %ACTIVITY%) COMPETING (COMPITIENDO en %ACTIVITY%), LISTENING (ESCUCHANDO %ACTIVITY%), WATCHING (MIRANDO %ACTIVITY%), STREAMING (EN STREAM de %ACTIVITY%), (CUSTOM = Don't type / Sin tipo de actividad)
77
STATUS: "ONLINE" # DO_NOT_DISTURB (NO MOLESTAR), IDLE (AUSENTE), INVISIBLE (INVISIBLE), (OFFLINE (DESCONECTADO) = Bot don't start / El bot no inicia)
8-
ACTIVITY: "spacehcf.us" # (CUSTOM Ex/Ej: Playing Bunkers-01 on spacehcf.us / Jugando a Bunkers-01 en spacehcf.us)
8+
ACTIVITY: "spacehcf.us" # (CUSTOM Ex/Ej: Playing Bunkers-01 on spacehcf.us / Jugando a Bunkers-01 en spacehcf.us)
9+
STREAM_URL: "https://twitch.tv/liteclubdevelopment" # ONLY WORKS IF ACTIVITY TYPE IS "STREAMING" / SOLO FUNCIONA SI ACTIVITY TYPE ES "STREAMING"

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Bot
2-
version: 1.0
2+
version: 1.1
33
main: club.lite.bot.Bot
44
description: Simple Discord Bot Status Plugin
55
website: https://dsc.gg/liteclubdevelopment

0 commit comments

Comments
 (0)