cleanup
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m42s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 1m42s
This commit is contained in:
@ -0,0 +1,52 @@
|
||||
package cc.fascinated.bat.leveling.command;
|
||||
|
||||
import cc.fascinated.bat.common.command.BatCommand;
|
||||
import cc.fascinated.bat.common.command.CommandInfo;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
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;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
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
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, Message commandMessage, String[] arguments, SlashCommandInteraction event) {
|
||||
OptionMapping userOption = event.getOption("user");
|
||||
assert userOption != null;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user