Add placeholder support to presence updater

This commit is contained in:
Vankka 2024-11-30 13:30:38 +02:00
parent d6c1d22b64
commit 7e5f1b5a79
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
2 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,7 @@
package com.discordsrv.common.config.main;
import com.discordsrv.common.DiscordSRV;
import com.discordsrv.common.config.configurate.annotation.Constants;
import com.discordsrv.common.core.logging.Logger;
import net.dv8tion.jda.api.OnlineStatus;
@ -75,7 +76,7 @@ public class PresenceUpdaterConfig {
})
public String activity = "playing Minecraft";
public Activity activity(Logger logger) {
public Activity activity(Logger logger, DiscordSRV discordSRV) {
Activity.ActivityType activityType = Activity.ActivityType.CUSTOM_STATUS;
String activity = this.activity;
String url = null;
@ -115,7 +116,11 @@ public class PresenceUpdaterConfig {
break;
}
return Activity.of(activityType, activity, url);
return Activity.of(
activityType,
discordSRV.placeholderService().replacePlaceholders(activity),
url
);
}
}
}

View File

@ -79,7 +79,7 @@ public class PresenceUpdaterModule extends AbstractModule<DiscordSRV> {
// Log problems with presences
for (PresenceUpdaterConfig.Presence presence : discordSRV.config().presenceUpdater.presences) {
presence.activity(logger());
presence.activity(logger(), discordSRV);
}
}
@ -89,7 +89,7 @@ public class PresenceUpdaterModule extends AbstractModule<DiscordSRV> {
// Guess not
return;
}
jda.getPresence().setPresence(config.status, config.activity(null));
jda.getPresence().setPresence(config.status, config.activity(null, discordSRV));
}
private void setPresenceOrSchedule() {