diff --git a/src/main/java/cc/fascinated/bat/command/BatCommand.java b/src/main/java/cc/fascinated/bat/command/BatCommand.java index 2f50a2f..58a03ea 100644 --- a/src/main/java/cc/fascinated/bat/command/BatCommand.java +++ b/src/main/java/cc/fascinated/bat/command/BatCommand.java @@ -88,7 +88,7 @@ public abstract class BatCommand implements BatCommandExecutor { * @param description the description of the option * @param required whether the option is required */ - private void addOption(OptionType optionType, String name, String description, boolean required) { + protected void addOption(OptionType optionType, String name, String description, boolean required) { this.commandData.addOption(optionType, name, description, required); } diff --git a/src/main/java/cc/fascinated/bat/command/impl/AvatarCommand.java b/src/main/java/cc/fascinated/bat/command/impl/AvatarCommand.java new file mode 100644 index 0000000..5356014 --- /dev/null +++ b/src/main/java/cc/fascinated/bat/command/impl/AvatarCommand.java @@ -0,0 +1,41 @@ +package cc.fascinated.bat.command.impl; + +import cc.fascinated.bat.command.BatCommand; +import cc.fascinated.bat.common.EmbedUtils; +import cc.fascinated.bat.model.BatGuild; +import cc.fascinated.bat.model.BatUser; +import lombok.NonNull; +import net.dv8tion.jda.api.entities.Member; +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 org.springframework.stereotype.Component; + +/** + * @author Fascinated (fascinated7) + */ +@Component +public class AvatarCommand extends BatCommand { + public AvatarCommand() { + super("avatar", "Gets the avatar of a user"); + super.addOption(OptionType.USER, "user", "The user to get the avatar of", true); + } + + @Override + public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) { + OptionMapping userOption = interaction.getOption("user"); + if (userOption == null) { + interaction.reply("You must provide a user to get the avatar of!").queue(); + return; + } + + User target = userOption.getAsUser(); + interaction.replyEmbeds(EmbedUtils.genericEmbed() + .setAuthor("%s's Avatar".formatted(target.getName()), null, target.getEffectiveAvatarUrl()) + .setImage(target.getAvatar().getUrl(4096)) + .build() + ).queue(); + } +} diff --git a/src/main/java/cc/fascinated/bat/command/impl/PingCommand.java b/src/main/java/cc/fascinated/bat/command/impl/PingCommand.java index ec53e37..b627b92 100644 --- a/src/main/java/cc/fascinated/bat/command/impl/PingCommand.java +++ b/src/main/java/cc/fascinated/bat/command/impl/PingCommand.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Component; */ @Component public class PingCommand extends BatCommand { - public PingCommand() { super("ping", "Gets the ping of the bot"); } diff --git a/src/main/java/cc/fascinated/bat/common/EmbedUtils.java b/src/main/java/cc/fascinated/bat/common/EmbedUtils.java index 5e45621..ba49620 100644 --- a/src/main/java/cc/fascinated/bat/common/EmbedUtils.java +++ b/src/main/java/cc/fascinated/bat/common/EmbedUtils.java @@ -10,7 +10,6 @@ import java.time.LocalDateTime; */ @UtilityClass public class EmbedUtils { - /** * Builds a generic embed * diff --git a/src/main/java/cc/fascinated/bat/common/ProfileHolder.java b/src/main/java/cc/fascinated/bat/common/ProfileHolder.java index b931457..6a38aef 100644 --- a/src/main/java/cc/fascinated/bat/common/ProfileHolder.java +++ b/src/main/java/cc/fascinated/bat/common/ProfileHolder.java @@ -10,7 +10,6 @@ import java.util.Map; */ @Getter public class ProfileHolder { - /** * The profiles for the holder */ diff --git a/src/main/java/cc/fascinated/bat/common/WebRequest.java b/src/main/java/cc/fascinated/bat/common/WebRequest.java index 6f4eecc..f59dd98 100644 --- a/src/main/java/cc/fascinated/bat/common/WebRequest.java +++ b/src/main/java/cc/fascinated/bat/common/WebRequest.java @@ -10,7 +10,6 @@ import org.springframework.web.client.RestClient; @UtilityClass public class WebRequest { - /** * The web client. */