forked from Fascinated/Bat
42 lines
1.6 KiB
Java
42 lines
1.6 KiB
Java
|
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();
|
||
|
}
|
||
|
}
|