add rotating presences
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 44s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 44s
This commit is contained in:
parent
e9422793cb
commit
0f2c684300
@ -15,8 +15,8 @@ import org.springframework.stereotype.Component;
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component("scoresaber-number-one-feed")
|
||||
public class NunberOneFeedCommand extends BatCommand {
|
||||
public NunberOneFeedCommand(@NonNull ApplicationContext context) {
|
||||
public class NumberOneFeedCommand extends BatCommand {
|
||||
public NumberOneFeedCommand(@NonNull ApplicationContext context) {
|
||||
super("scoresaber-number-one-feed");
|
||||
super.setCategory(Category.BEAT_SABER);
|
||||
|
@ -3,7 +3,7 @@ package cc.fascinated.bat.service;
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.features.scoresaber.command.numberone.NunberOneFeedCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.numberone.NumberOneFeedCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.userfeed.UserFeedCommand;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
@ -52,7 +52,7 @@ public class CommandService extends ListenerAdapter {
|
||||
|
||||
// Guild commands
|
||||
registerCommand(context.getBean(UserFeedCommand.class));
|
||||
registerCommand(context.getBean(NunberOneFeedCommand.class));
|
||||
registerCommand(context.getBean(NumberOneFeedCommand.class));
|
||||
|
||||
// Global commands
|
||||
registerCommand(context.getBean(ScoreSaberCommand.class));
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
@ -22,6 +23,13 @@ public class DiscordService {
|
||||
*/
|
||||
public static JDA JDA;
|
||||
|
||||
private final List<String> messages = List.of(
|
||||
"over {guilds} guilds",
|
||||
"over {users} users",
|
||||
"over ScoreSaber scores",
|
||||
"your messages"
|
||||
);
|
||||
|
||||
@Autowired
|
||||
public DiscordService(
|
||||
@Value("${discord.token}") String token
|
||||
@ -31,9 +39,7 @@ public class DiscordService {
|
||||
GatewayIntent.MESSAGE_CONTENT
|
||||
)).build()
|
||||
.awaitReady();
|
||||
|
||||
// Update activity every 5 minutes
|
||||
TimerUtils.scheduleRepeating(this::updateActivity, 0, 1000 * 60 * 5);
|
||||
TimerUtils.scheduleRepeating(this::updateActivity, 0, 1000 * 60 * 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,6 +47,9 @@ public class DiscordService {
|
||||
*/
|
||||
public void updateActivity() {
|
||||
int guildCount = JDA.getGuilds().size();
|
||||
JDA.getPresence().setActivity(Activity.playing("with %s guilds".formatted(guildCount)));
|
||||
JDA.getPresence().setActivity(Activity.watching(messages.get(guildCount % messages.size())
|
||||
.replace("{guilds}", String.valueOf(guildCount))
|
||||
.replace("{users}", String.valueOf(JDA.getUsers().size()))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user