2024-12-27 13:04:57 +00:00
|
|
|
package cc.fascinated.bat.leveling.command;
|
2024-07-06 04:04:38 +01:00
|
|
|
|
2024-12-27 13:04:57 +00:00
|
|
|
import cc.fascinated.bat.common.command.BatCommand;
|
|
|
|
import cc.fascinated.bat.common.command.CommandInfo;
|
2024-07-06 04:04:38 +01:00
|
|
|
import cc.fascinated.bat.common.EmbedUtils;
|
2024-12-27 13:04:57 +00:00
|
|
|
import cc.fascinated.bat.leveling.LevelingProfile;
|
|
|
|
import cc.fascinated.bat.leveling.UserLevel;
|
|
|
|
import cc.fascinated.bat.common.model.BatGuild;
|
|
|
|
import cc.fascinated.bat.common.model.BatUser;
|
2024-07-06 04:04:38 +01:00
|
|
|
import lombok.NonNull;
|
|
|
|
import net.dv8tion.jda.api.Permission;
|
|
|
|
import net.dv8tion.jda.api.entities.Member;
|
2024-07-16 14:35:02 +01:00
|
|
|
import net.dv8tion.jda.api.entities.Message;
|
2024-07-06 04:04:38 +01:00
|
|
|
import net.dv8tion.jda.api.entities.User;
|
|
|
|
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
|
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Fascinated (fascinated7)
|
|
|
|
*/
|
|
|
|
@Component("leveling.reset:sub")
|
|
|
|
@CommandInfo(
|
|
|
|
name = "reset",
|
|
|
|
description = "Resets the level and xp of the user",
|
|
|
|
requiredPermissions = Permission.MANAGE_SERVER
|
|
|
|
)
|
|
|
|
public class ResetSubCommand extends BatCommand {
|
|
|
|
public ResetSubCommand() {
|
|
|
|
super.addOptions(
|
|
|
|
new OptionData(OptionType.USER, "user", "The user to reset", true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-07-16 14:35:02 +01:00
|
|
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, Message commandMessage, String[] arguments, SlashCommandInteraction event) {
|
2024-07-06 04:04:38 +01:00
|
|
|
OptionMapping userOption = event.getOption("user");
|
2024-07-07 02:18:10 +01:00
|
|
|
assert userOption != null;
|
|
|
|
|
2024-07-06 04:04:38 +01:00
|
|
|
User target = userOption.getAsUser();
|
|
|
|
LevelingProfile profile = guild.getLevelingProfile();
|
|
|
|
UserLevel level = profile.getUserLevel(target.getId());
|
|
|
|
|
|
|
|
level.reset();
|
|
|
|
event.replyEmbeds(EmbedUtils.successEmbed()
|
|
|
|
.setDescription("Reset Level and XP for %s!".formatted(target.getAsMention()))
|
|
|
|
.build()).queue();
|
|
|
|
}
|
|
|
|
}
|