finalize previous commit

This commit is contained in:
Anya 2022-03-30 09:39:07 -07:00
parent 7f9d7f3443
commit 5ba6039d4a
2 changed files with 63 additions and 4 deletions

View file

@ -31,7 +31,7 @@ public class AvatarCommand extends CommandClass {
EmbedBuilder eb = new EmbedBuilder()
.setColor(EmbedUI.INFO)
.setAuthor(user.getName())
.setAuthor(user.getName() + "#" + user.getDiscriminator())
.setImage(user.getEffectiveAvatarUrl() + "?size=2048")
.setFooter(EmbedUI.BRAND)
.setTimestamp(ZonedDateTime.now());

View file

@ -1,24 +1,83 @@
package moe.oko.Kiafumi.command;
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.entities.Role;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
public class WhoIsCommand extends CommandClass{
public class InfoCommand extends CommandClass{
@Override
public boolean isEnabled() { return false; }
@Override
public String getName() { return "WHOIS"; }
public String getName() { return "Info"; }
@Override
public void newCommand(String name, SlashCommandInteractionEvent e) {
switch (name){
case "userinfo":
e.deferReply().queue();
// Setup variables
final var member = e.getOptions().size() == 0
? e.getMember()
: e.getOption("user").getAsMember();
final var dTF = DateTimeFormatter.ofPattern("MM-dd-yyyy");
// Build embed
EmbedBuilder eb1 = new EmbedBuilder()
.setColor(EmbedUI.INFO)
.setAuthor(member.getEffectiveName() + "#" + member.getUser().getDiscriminator())
.addField("Joined Server", member.getTimeJoined().format(dTF), true)
.addField("Joined Discord", member.getTimeCreated().format(dTF), true)
.addField("Roles", member.getRoles().stream().map(Role::getName).reduce((a, b) -> a + ", " + b).orElse("None"), false)
.setThumbnail(member.getEffectiveAvatarUrl())
.setFooter("ID: " + member.getId())
.setTimestamp(ZonedDateTime.now());
e.getHook().sendMessageEmbeds(eb1.build()).queue();
return;
case "serverinfo":
e.deferReply().queue();
// Setup variables
final var guild = e.getGuild();
final var dTF2 = DateTimeFormatter.ofPattern("MM-dd-yyyy");
// Build Embed
EmbedBuilder eb2 = new EmbedBuilder()
.setColor(EmbedUI.INFO)
.setAuthor(guild.getName())
.addField("Members", "**" + guild.getMemberCount() + "** member(s) \n Owner: "
+ guild.getOwner().getEffectiveName() + "#" + guild.getOwner().getUser().getDiscriminator(), true)
.addField("Channels", "**" + guild.getTextChannels().size() + "** Text \n **"
+ guild.getVoiceChannels().size() + "** Voice", true)
.addField("Other", "Roles: **" + guild.getRoles().size() + "** \n"
+ "Created: " + guild.getTimeCreated().format(dTF2), true)
.setThumbnail(guild.getIconUrl())
.setFooter("ID: " + guild.getId());
e.getHook().sendMessageEmbeds(eb2.build()).queue();
}
}
@Override
public List<CommandInfo> getSlashCommandInfo() {
return null;
List<CommandInfo> cil = new ArrayList<>();
CommandInfo ci = new CommandInfo("userinfo", "Returns information about a user.", CommandType.COMMAND);
ci.addOption("user", "The user to get information about.", OptionType.USER, false);
CommandInfo ci2 = new CommandInfo("serverinfo", "Returns information about the server.", CommandType.COMMAND);
cil.add(ci);
cil.add(ci2);
return cil;
}
}