Add sdate & Rename dreidel

This commit is contained in:
Anya 2022-03-29 20:52:10 -07:00
parent f8396f89f8
commit c07b3c19e1
4 changed files with 65 additions and 13 deletions

View File

@ -80,7 +80,8 @@ public class Kiafumi {
activeCommands.add(new SettingCommand()); activeCommands.add(new SettingCommand());
activeCommands.add(new DuckCommand()); activeCommands.add(new DuckCommand());
activeCommands.add(new InviteCommand()); activeCommands.add(new InviteCommand());
activeCommands.add(new DreidelCommand()); activeCommands.add(new FightCommand());
activeCommands.add(new SeptemberDateCommand());
instance = this; instance = this;

View File

@ -15,8 +15,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
// TODO: Make this actually a Dreidel, and use this code for a fight command. public class FightCommand extends CommandClass {
public class DreidelCommand extends CommandClass {
private boolean enabled = false; private boolean enabled = false;
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
@ -25,12 +24,12 @@ public class DreidelCommand extends CommandClass {
@Override @Override
public String getName() { public String getName() {
return "Dreidel"; return "Fight";
} }
@Override @Override
public void newCommand(String name, SlashCommandInteractionEvent e) { public void newCommand(String name, SlashCommandInteractionEvent e) {
if ("dreidel".equals(name)) { if ("fight".equals(name)) {
e.deferReply().queue(); e.deferReply().queue();
List<User> usersForRng = new ArrayList<>(); List<User> usersForRng = new ArrayList<>();
List<String> userNames = new ArrayList<>(); List<String> userNames = new ArrayList<>();
@ -50,8 +49,8 @@ public class DreidelCommand extends CommandClass {
User pickedUser = usersForRng.get(rng.nextInt(usersForRng.size())); User pickedUser = usersForRng.get(rng.nextInt(usersForRng.size()));
EmbedBuilder eb1 = new EmbedBuilder() EmbedBuilder eb1 = new EmbedBuilder()
.setColor(EmbedUI.INFO) .setColor(EmbedUI.INFO)
.setTitle("The dreidel has spoken...") .setTitle("VICTORY!")
.setDescription(pickedUser.getName() + " is the lucky winner!") .setDescription(pickedUser.getName() + " is the survivor!")
.setThumbnail(pickedUser.getAvatarUrl()) .setThumbnail(pickedUser.getAvatarUrl())
.setFooter(EmbedUI.BRAND) // TODO: Make this show the list of participants .setFooter(EmbedUI.BRAND) // TODO: Make this show the list of participants
.setTimestamp(ZonedDateTime.now()); .setTimestamp(ZonedDateTime.now());
@ -62,11 +61,11 @@ public class DreidelCommand extends CommandClass {
@Override @Override
public List<CommandInfo> getSlashCommandInfo() { public List<CommandInfo> getSlashCommandInfo() {
List<CommandInfo> cil = new ArrayList<>(); List<CommandInfo> cil = new ArrayList<>();
CommandInfo ci = new CommandInfo("dreidel", "picks a random person out of 4 values.", CommandType.COMMAND); CommandInfo ci = new CommandInfo("fight", "MORTALLL KOMBATTTT", CommandType.COMMAND);
ci.addOption("value1", "first value for spin", OptionType.USER, true); ci.addOption("value1", "first fighter", OptionType.USER, true);
ci.addOption("value2", "second value for spin", OptionType.USER, true); ci.addOption("value2", "second fighter", OptionType.USER, true);
ci.addOption("value3", "third value for spin", OptionType.USER, false); ci.addOption("value3", "third fighter", OptionType.USER, false);
ci.addOption("value4", "fourth value for spin", OptionType.USER, false); ci.addOption("value4", "fourth fighter", OptionType.USER, false);
cil.add(ci); cil.add(ci);
return cil; return cil;
} }

View File

@ -0,0 +1,52 @@
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.events.interaction.command.SlashCommandInteractionEvent;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
public class SeptemberDateCommand extends CommandClass {
@Override
public boolean isEnabled() { return true; }
@Override
public String getName() { return "SeptemberDate"; }
@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
var sdate = ChronoUnit.DAYS.between(september, now);
EmbedBuilder eb = new EmbedBuilder()
.setColor(EmbedUI.INFO)
.setTitle("sdate")
.setDescription("Today is September, " + sdate + " 1993, the september that never ends")
.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("sdate", "Returns the Eternal September date.", CommandType.COMMAND);
cil.add(ci);
return cil;
}
}

View File

@ -61,7 +61,7 @@ public class MainListener extends ListenerAdapter {
.setColor(EmbedUI.INFO) .setColor(EmbedUI.INFO)
.setTitle("Hi, i'm Kiafumi!") .setTitle("Hi, i'm Kiafumi!")
.setDescription("I was summoned on October 6th 2017! My goal is to explore the metaverse and help people in it!") .setDescription("I was summoned on October 6th 2017! My goal is to explore the metaverse and help people in it!")
.setImage(Kiafumi.JDA.getSelfUser().getAvatarUrl()) .setThumbnail(Kiafumi.JDA.getSelfUser().getAvatarUrl())
.setTimestamp(ZonedDateTime.now()) .setTimestamp(ZonedDateTime.now())
.setFooter(EmbedUI.BRAND); .setFooter(EmbedUI.BRAND);
event.getChannel().sendMessageEmbeds(eb.build()).queue(); event.getChannel().sendMessageEmbeds(eb.build()).queue();