cleanup bot admin

This commit is contained in:
Lee 2024-07-06 17:26:31 +01:00
parent 9379ebb33d
commit d90bdfe3b6
6 changed files with 40 additions and 33 deletions

@ -2,7 +2,7 @@ package cc.fascinated.bat.features.base;
import cc.fascinated.bat.features.Feature; import cc.fascinated.bat.features.Feature;
import cc.fascinated.bat.features.FeatureProfile; import cc.fascinated.bat.features.FeatureProfile;
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumAdminCommand; import cc.fascinated.bat.features.base.commands.botadmin.BotAdminCommand;
import cc.fascinated.bat.features.base.commands.fun.EightBallCommand; import cc.fascinated.bat.features.base.commands.fun.EightBallCommand;
import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand; import cc.fascinated.bat.features.base.commands.fun.image.ImageCommand;
import cc.fascinated.bat.features.base.commands.general.*; import cc.fascinated.bat.features.base.commands.general.*;
@ -28,7 +28,7 @@ public class BaseFeature extends Feature {
super("Base", FeatureProfile.FeatureState.DISABLED, false); super("Base", FeatureProfile.FeatureState.DISABLED, false);
super.registerCommand(commandService, context.getBean(PremiumCommand.class)); super.registerCommand(commandService, context.getBean(PremiumCommand.class));
super.registerCommand(commandService, context.getBean(PremiumAdminCommand.class)); super.registerCommand(commandService, context.getBean(BotAdminCommand.class));
super.registerCommand(commandService, context.getBean(MemberCountCommand.class)); super.registerCommand(commandService, context.getBean(MemberCountCommand.class));
super.registerCommand(commandService, context.getBean(ChannelCommand.class)); super.registerCommand(commandService, context.getBean(ChannelCommand.class));
super.registerCommand(commandService, context.getBean(VoteCommand.class)); super.registerCommand(commandService, context.getBean(VoteCommand.class));

@ -0,0 +1,25 @@
package cc.fascinated.bat.features.base.commands.botadmin;
import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumRemoveSubCommand;
import cc.fascinated.bat.features.base.commands.botadmin.premium.PremiumSetSubCommand;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
@Component
@CommandInfo(name = "bot-admin", description = "Bot admin commands", botOwnerOnly = true)
public class BotAdminCommand extends BatCommand {
@Autowired
public BotAdminCommand(@NonNull ApplicationContext context) {
super.addSubCommands(
context.getBean(PremiumSetSubCommand.class),
context.getBean(PremiumRemoveSubCommand.class)
);
}
}

@ -1,23 +0,0 @@
package cc.fascinated.bat.features.base.commands.botadmin.premium;
import cc.fascinated.bat.command.BatCommand;
import cc.fascinated.bat.command.CommandInfo;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
@Component
@CommandInfo(name = "premiumadmin", description = "Set a guild as premium", botOwnerOnly = true)
public class PremiumAdminCommand extends BatCommand {
@Autowired
public PremiumAdminCommand(@NonNull ApplicationContext context) {
super.addSubCommands(
context.getBean(SetSubCommand.class),
context.getBean(RemoveSubCommand.class)
);
}
}

@ -20,12 +20,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "remove", description = "Remove premium from a guild") @CommandInfo(name = "premium-remove", description = "Remove premium from a guild")
public class RemoveSubCommand extends BatCommand { public class PremiumRemoveSubCommand extends BatCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public RemoveSubCommand(GuildService guildService) { public PremiumRemoveSubCommand(GuildService guildService) {
this.guildService = guildService; this.guildService = guildService;
super.addOptions(new OptionData(OptionType.STRING, "guild", "The guild id to set as premium", true)); super.addOptions(new OptionData(OptionType.STRING, "guild", "The guild id to set as premium", true));
} }

@ -20,12 +20,12 @@ import org.springframework.stereotype.Component;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Component @Component
@CommandInfo(name = "set", description = "Adds premium to a guild") @CommandInfo(name = "premium-set", description = "Adds premium to a guild")
public class SetSubCommand extends BatCommand { public class PremiumSetSubCommand extends BatCommand {
private final GuildService guildService; private final GuildService guildService;
@Autowired @Autowired
public SetSubCommand(@NonNull GuildService guildService) { public PremiumSetSubCommand(@NonNull GuildService guildService) {
this.guildService = guildService; this.guildService = guildService;
super.addOptions( super.addOptions(
new OptionData(OptionType.STRING, "guild", "The guild id to set as premium", true), new OptionData(OptionType.STRING, "guild", "The guild id to set as premium", true),

@ -39,7 +39,7 @@ public class UserLevel {
public boolean canLevelUp() { public boolean canLevelUp() {
// Handle XP cooldown // Handle XP cooldown
long cooldown = System.currentTimeMillis() - this.lastXpTimestamp; long cooldown = System.currentTimeMillis() - this.lastXpTimestamp;
if (cooldown > 30_000) { if (cooldown < 30_000) {
return false; return false;
} }
this.lastXpTimestamp = System.currentTimeMillis(); this.lastXpTimestamp = System.currentTimeMillis();
@ -50,7 +50,12 @@ public class UserLevel {
* Levels up the user. * Levels up the user.
*/ */
public void levelup() { public void levelup() {
do {
if (this.currentXp < LevelingFeature.getNeededXP(this.level + 1, this.currentXp)) {
break;
}
this.level++; this.level++;
} while (this.currentXp >= LevelingFeature.getNeededXP(this.level + 1, this.currentXp));
} }
/** /**