From df8e0dc75268fe7a2edb7fe800a04bfd03aacaf0 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Fri, 22 Nov 2019 16:30:57 -0800 Subject: [PATCH] Avatar Command --- src/main/java/com/bbn/hadder/Hadder.java | 3 +- .../hadder/commands/fun/AvatarCommand.java | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index eede5b60..ce0ae2cb 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -70,6 +70,7 @@ private static void startBot() { new RoleCommand(), new RulesCommand(), new FeedbackCommand(), + new AvatarCommand(), new LinkCommand()), config, helpCommand); builder.addEventListeners( @@ -80,7 +81,7 @@ private static void startBot() { new ReadyListener(rethink, config), new LinkListener(rethink), new RulesListener(rethink)); - + try { shardManager = builder.build(); diff --git a/src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java b/src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java new file mode 100644 index 00000000..e45b9497 --- /dev/null +++ b/src/main/java/com/bbn/hadder/commands/fun/AvatarCommand.java @@ -0,0 +1,57 @@ +package com.bbn.hadder.commands.fun; + +/* + * @author Skidder / GregTCLTK + */ + +import com.bbn.hadder.commands.Command; +import com.bbn.hadder.commands.CommandEvent; +import com.bbn.hadder.utils.MessageEditor; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; + +public class AvatarCommand implements Command { + + @Override + public void executed(String[] args, CommandEvent event) { + if (args.length == 0) { + Member member = event.getMember(); + event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() + .setTitle("Avatar of " + member.getUser().getAsTag())) + .setImage(member.getUser().getAvatarUrl()) + .setFooter(member.getUser().getAsTag()) + .build()).queue(); + } else if (event.getMessage().getMentionedMembers().size() == 1) { + Member member = event.getMessage().getMentionedMembers().get(0); + event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() + .setTitle("Avatar of " + member.getUser().getAsTag())) + .setImage(member.getUser().getAvatarUrl()) + .setFooter(member.getUser().getAsTag()) + .build()).queue(); + } else if (args[0].length() == 18){ + Member member = event.getGuild().getMemberById(args[0]); + event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO, new EmbedBuilder() + .setTitle("Avatar of " + member.getUser().getAsTag())) + .setImage(member.getUser().getAvatarUrl()) + .setFooter(member.getUser().getAsTag()) + .build()).queue(); + } else { + event.getHelpCommand().sendHelp(this , event.getRethink(), event.getAuthor(), event.getTextChannel()); + } + } + + @Override + public String[] labels() { + return new String[]{"avatar"}; + } + + @Override + public String description() { + return "Sends the avatar of the specified member."; + } + + @Override + public String usage() { + return "<@User>/"; + } +}