57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package moe.oko.Kiafumi.command.image;
|
|
|
|
import moe.oko.Kiafumi.command.CommandClass;
|
|
import moe.oko.Kiafumi.util.CommandInfo;
|
|
import moe.oko.Kiafumi.util.CommandType;
|
|
import moe.oko.Kiafumi.util.EmbedUI;
|
|
import net.dv8tion.jda.api.EmbedBuilder;
|
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|
|
|
import java.time.ZonedDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import static moe.oko.Kiafumi.util.LoggingManager.slashLog;
|
|
|
|
/**
|
|
* Helpful Avatar grabber command
|
|
* @author oko
|
|
*/
|
|
public class AvatarCommand extends CommandClass {
|
|
@Override
|
|
public boolean isEnabled() { return true; }
|
|
|
|
@Override
|
|
public String getName() { return "Avatar"; }
|
|
|
|
@Override
|
|
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
|
if ("avatar".equals(name)) {
|
|
e.deferReply().queue();
|
|
|
|
final var user = e.getOptions().size() == 0
|
|
? e.getUser()
|
|
: e.getOption("user").getAsUser();
|
|
slashLog(e, "for user [" + user.getName() + ":" + user.getId() + "]." );
|
|
|
|
var eb = new EmbedBuilder()
|
|
.setColor(EmbedUI.INFO)
|
|
.setAuthor(user.getName() + "#" + user.getDiscriminator())
|
|
.setImage(user.getEffectiveAvatarUrl() + "?size=2048")
|
|
.setFooter(EmbedUI.BRAND)
|
|
.setTimestamp(ZonedDateTime.now());
|
|
e.getHook().sendMessageEmbeds(eb.build()).queue();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public List<CommandInfo> getSlashCommandInfo() {
|
|
List<CommandInfo> cil = new ArrayList<>();
|
|
var ci = new CommandInfo("avatar", "Returns the avatar of the specified user.", CommandType.COMMAND);
|
|
ci.addOption("user", "User to fetch.", OptionType.USER, false);
|
|
cil.add(ci);
|
|
return cil;
|
|
}
|
|
}
|