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.common.model.BatGuild;
|
||||
import cc.fascinated.bat.common.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.unions.GuildChannelUnion;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component("leveling.channel:sub")
|
||||
@CommandInfo(
|
||||
name = "channel",
|
||||
description = "Sets the notification channel for leveling"
|
||||
)
|
||||
public class ChannelSubCommand extends BatCommand {
|
||||
@Autowired
|
||||
public ChannelSubCommand() {
|
||||
super.addOptions(
|
||||
new OptionData(OptionType.CHANNEL, "channel", "The channel to set as the notification channel", true)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, Message commandMessage, String[] arguments, SlashCommandInteraction event) {
|
||||
OptionMapping channelOption = event.getOption("channel");
|
||||
assert channelOption != null;
|
||||
|
||||
GuildChannelUnion channelUnion = channelOption.getAsChannel();
|
||||
TextChannel textChannel = channelUnion.asTextChannel();
|
||||
LevelingProfile profile = guild.getLevelingProfile();
|
||||
|
||||
profile.setNotificationChannelId(textChannel.getId());
|
||||
event.replyEmbeds(EmbedUtils.successEmbed()
|
||||
.setDescription("Successfully set the notification channel to %s".formatted(textChannel.getAsMention()))
|
||||
.build()).queue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user