Update SeptemberDateCommand & add AvatarCommand
SeptemberDateCommand's date should now be accurate. AvatarCommand fetches the specified user's avatar.
This commit is contained in:
parent
221204611c
commit
523ce4173d
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||
*/
|
||||
public class Kiafumi {
|
||||
|
||||
private File CONFIG_FILE = new File("config.yml");
|
||||
private final File CONFIG_FILE = new File("config.yml");
|
||||
|
||||
public YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
||||
|
||||
|
@ -82,6 +82,7 @@ public class Kiafumi {
|
|||
activeCommands.add(new InviteCommand());
|
||||
activeCommands.add(new MusicCommand());
|
||||
activeCommands.add(new FightCommand());
|
||||
activeCommands.add(new AvatarCommand());
|
||||
activeCommands.add(new SeptemberDateCommand());
|
||||
activeCommands.add(new DreidelCommand());
|
||||
|
||||
|
|
50
src/main/java/moe/oko/Kiafumi/command/AvatarCommand.java
Normal file
50
src/main/java/moe/oko/Kiafumi/command/AvatarCommand.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package moe.oko.Kiafumi.command;
|
||||
|
||||
import moe.oko.Kiafumi.Kiafumi;
|
||||
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 java.util.Locale;
|
||||
|
||||
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();
|
||||
|
||||
EmbedBuilder eb = new EmbedBuilder()
|
||||
.setColor(EmbedUI.INFO)
|
||||
.setAuthor(user.getName())
|
||||
.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<>();
|
||||
CommandInfo 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;
|
||||
}
|
||||
}
|
|
@ -21,12 +21,13 @@ public class SeptemberDateCommand extends CommandClass {
|
|||
@Override
|
||||
public String getName() { return "SeptemberDate"; }
|
||||
|
||||
final LocalDate september = LocalDate.of(1993, Month.AUGUST, 31);
|
||||
|
||||
@Override
|
||||
public void newCommand(String name, SlashCommandInteractionEvent e) {
|
||||
if ("sdate".equals(name)) {
|
||||
e.deferReply().queue();
|
||||
// Setup vars
|
||||
final var september = LocalDate.of(1993, Month.SEPTEMBER, 30);
|
||||
|
||||
var now = LocalDate.now();
|
||||
|
||||
// Create the Eternal September date
|
||||
|
|
Loading…
Reference in a new issue