Compare commits

...

2 commits

Author SHA1 Message Date
Anya 5ba6039d4a finalize previous commit 2022-03-30 09:39:07 -07:00
Anya 7f9d7f3443 Add User/Server info commands, fix Avatar command 2022-03-30 09:37:57 -07:00
3 changed files with 86 additions and 1 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

@ -0,0 +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 InfoCommand extends CommandClass{
@Override
public boolean isEnabled() { return false; }
@Override
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() {
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;
}
}

View file

@ -0,0 +1,2 @@
package moe.oko.Kiafumi.command;public class StatsCommand {
}