forked from Fascinated/Bat
add avatar command
This commit is contained in:
parent
47beff752c
commit
aec2fe1c2b
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@UtilityClass
|
||||
public class EmbedUtils {
|
||||
|
||||
/**
|
||||
* Builds a generic embed
|
||||
*
|
||||
|
@ -10,7 +10,6 @@ import java.util.Map;
|
||||
*/
|
||||
@Getter
|
||||
public class ProfileHolder {
|
||||
|
||||
/**
|
||||
* The profiles for the holder
|
||||
*/
|
||||
|
@ -10,7 +10,6 @@ import org.springframework.web.client.RestClient;
|
||||
|
||||
@UtilityClass
|
||||
public class WebRequest {
|
||||
|
||||
/**
|
||||
* The web client.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user