Skip to content

Commit

Permalink
* Added actual support for an extra beta token.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Aug 9, 2022
1 parent f8df1aa commit 9a324bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/java/de/presti/ree6/bot/BotWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ private BotWorker() {
*/
public static void createBot(BotVersion version1, String build1) throws LoginException {
version = version1;
token = BotWorker.version == BotVersion.DEVELOPMENT_BUILD ? Main.getInstance().getConfig().getConfiguration().getString("bot.tokens.dev") : Main.getInstance().getConfig().getConfiguration().getString("bot.tokens.rel");
token = BotWorker.version == BotVersion.DEVELOPMENT_BUILD ?
Main.getInstance().getConfig().getConfiguration().getString("bot.tokens.dev") :
BotWorker.version == BotVersion.BETA_BUILD ?
Main.getInstance().getConfig().getConfiguration().getString("bot.tokens.beta") :
Main.getInstance().getConfig().getConfiguration().getString("bot.tokens.release");
state = BotState.INIT;
build = build1;

shardManager = DefaultShardManagerBuilder.createDefault(token).setShardsTotal(getVersion() == BotVersion.DEVELOPMENT_BUILD ? 1 : 10).enableIntents(GatewayIntent.GUILD_MESSAGES,
GatewayIntent.GUILD_INVITES, GatewayIntent.DIRECT_MESSAGES, GatewayIntent.GUILD_INVITES, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.GUILD_WEBHOOKS,
GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_BANS).setMemberCachePolicy(MemberCachePolicy.ALL).disableCache(CacheFlag.EMOJI, CacheFlag.ACTIVITY).build();
shardManager = DefaultShardManagerBuilder.createDefault(token).setShardsTotal(getVersion() == BotVersion.DEVELOPMENT_BUILD ? 1 : 10).enableIntents(GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_INVITES, GatewayIntent.DIRECT_MESSAGES, GatewayIntent.GUILD_INVITES, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.GUILD_WEBHOOKS, GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_BANS).setMemberCachePolicy(MemberCachePolicy.ALL).disableCache(CacheFlag.EMOJI, CacheFlag.ACTIVITY).build();
}

/**
Expand All @@ -99,8 +101,7 @@ public static void setActivity(String message, Activity.ActivityType activityTyp
public static void setActivity(JDA jda, String message, Activity.ActivityType activityType) {
// If the Bot Instance is null, if not set.
if (jda != null)
jda.getPresence().setActivity(Activity.of(activityType, message.replace("%shards%", shardManager.getShardsTotal() + "")
.replace("%shard%", "" + jda.getShardInfo().getShardId()).replace("%guilds%", shardManager.getGuilds().size() + "").replace("%shard_guilds%", jda.getGuilds().size() + "")));
jda.getPresence().setActivity(Activity.of(activityType, message.replace("%shards%", shardManager.getShardsTotal() + "").replace("%shard%", "" + jda.getShardInfo().getShardId()).replace("%guilds%", shardManager.getGuilds().size() + "").replace("%shard_guilds%", jda.getGuilds().size() + "")));
}

/**
Expand Down Expand Up @@ -136,6 +137,7 @@ public static Color randomEmbedColor() {

/**
* Change the current Bot State.
*
* @param botState the new {@link BotState}
*/
public static void setState(BotState botState) {
Expand All @@ -144,6 +146,7 @@ public static void setState(BotState botState) {

/**
* Get the current Bot State.
*
* @return the {@link BotState}.
*/
public static BotState getState() {
Expand All @@ -152,6 +155,7 @@ public static BotState getState() {

/**
* Get the current Bot Version.
*
* @return the {@link BotVersion}
*/
public static BotVersion getVersion() {
Expand All @@ -160,6 +164,7 @@ public static BotVersion getVersion() {

/**
* Get the ShardManager of Ree6.
*
* @return the {@link ShardManager}
*/
public static ShardManager getShardManager() {
Expand All @@ -168,6 +173,7 @@ public static ShardManager getShardManager() {

/**
* Get the build / the actual version in the x.y.z format.
*
* @return the Build.
*/
public static String getBuild() {
Expand All @@ -176,6 +182,7 @@ public static String getBuild() {

/**
* Set the start Time of the Bot.
*
* @param startTime1 the new start Time.
*/
public static void setStartTime(long startTime1) {
Expand All @@ -184,6 +191,7 @@ public static void setStartTime(long startTime1) {

/**
* Get the start Time of the Bot.
*
* @return the start Time.
*/
public static long getStartTime() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/presti/ree6/utils/data/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void init() {
yamlFile.addDefault("instagram.password", "yourInstagramPassword");
yamlFile.addDefault("youtube.api.key", "youryoutubeapikey");
yamlFile.addDefault("bot.tokens.rel", "ReleaseTokenhere");
yamlFile.addDefault("bot.tokens.beta", "BetaTokenhere");
yamlFile.addDefault("bot.tokens.dev", "DevTokenhere");

try {
Expand Down

0 comments on commit 9a324bb

Please sign in to comment.