Compare commits
2 Commits
0f54fe856e
...
5e48652587
Author | SHA1 | Date | |
---|---|---|---|
5e48652587 | |||
6ffe10e4c8 |
@ -3,7 +3,6 @@ package wtf.beatrice.hidekobot;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.OnlineStatus;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
import sun.misc.Signal;
|
||||
import wtf.beatrice.hidekobot.commands.completer.AvatarCommandCompleter;
|
||||
@ -123,6 +122,7 @@ public class HidekoBot
|
||||
slashCommandListener.registerCommand(new DieCommand());
|
||||
slashCommandListener.registerCommand(new HelpCommand());
|
||||
slashCommandListener.registerCommand(new InviteCommand());
|
||||
slashCommandListener.registerCommand(new LoveCalculatorCommand());
|
||||
slashCommandListener.registerCommand(new MagicBallCommand());
|
||||
slashCommandListener.registerCommand(new PingCommand());
|
||||
slashCommandListener.registerCommand(new SayCommand());
|
||||
|
@ -7,7 +7,6 @@ import net.dv8tion.jda.api.entities.channel.Channel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -0,0 +1,36 @@
|
||||
package wtf.beatrice.hidekobot.commands.base;
|
||||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.util.RandomUtil;
|
||||
|
||||
public class LoveCalculator
|
||||
{
|
||||
public static MessageEmbed buildEmbed(User author, User user1, User user2)
|
||||
{
|
||||
int loveAmount = RandomUtil.getRandomNumber(0, 100);
|
||||
|
||||
String formattedAmount = loveAmount + "%";
|
||||
if(loveAmount <= 30) formattedAmount += "... \uD83D\uDE22";
|
||||
else if(loveAmount < 60) formattedAmount += "! \uD83E\uDDD0";
|
||||
else if(loveAmount < 75) formattedAmount += "!!! \uD83E\uDD73";
|
||||
else formattedAmount = "✨ " + formattedAmount + "!!! \uD83D\uDE0D\uD83D\uDCA5";
|
||||
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
embedBuilder.setColor(Cache.getBotColor());
|
||||
embedBuilder.setAuthor(author.getAsTag(), null, author.getAvatarUrl());
|
||||
embedBuilder.setTitle("Love Calculator");
|
||||
|
||||
embedBuilder.addField("\uD83D\uDC65 People",
|
||||
user1.getAsMention() + " & " + user2.getAsMention(),
|
||||
false);
|
||||
|
||||
embedBuilder.addField("❤️\u200D\uD83D\uDD25 Match",
|
||||
formattedAmount,
|
||||
false);
|
||||
|
||||
return embedBuilder.build();
|
||||
}
|
||||
}
|
@ -17,7 +17,10 @@ import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.datasources.DatabaseSource;
|
||||
import wtf.beatrice.hidekobot.util.SerializationUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class UrbanDictionary
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.commands.base.Alias;
|
||||
import wtf.beatrice.hidekobot.commands.base.Say;
|
||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||
|
||||
|
@ -4,12 +4,14 @@ import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.IMentionable;
|
||||
import net.dv8tion.jda.api.entities.Mentions;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.HidekoBot;
|
||||
import wtf.beatrice.hidekobot.commands.base.LoveCalculator;
|
||||
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
||||
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
||||
import wtf.beatrice.hidekobot.util.RandomUtil;
|
||||
@ -86,28 +88,8 @@ public class LoveCalculatorCommand implements MessageCommand
|
||||
user2 = HidekoBot.getAPI().retrieveUserById(mentionedUserId).complete();
|
||||
}
|
||||
|
||||
int loveAmount = RandomUtil.getRandomNumber(0, 100);
|
||||
|
||||
String formattedAmount = loveAmount + "%";
|
||||
if(loveAmount <= 30) formattedAmount += "... \uD83D\uDE22";
|
||||
else if(loveAmount < 60) formattedAmount += "! \uD83E\uDDD0";
|
||||
else if(loveAmount < 75) formattedAmount += "!!! \uD83E\uDD73";
|
||||
else formattedAmount = "✨ " + formattedAmount + "!!! \uD83D\uDE0D\uD83D\uDCA5";
|
||||
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
embedBuilder.setColor(Cache.getBotColor());
|
||||
embedBuilder.setAuthor(event.getAuthor().getAsTag(), null, event.getAuthor().getAvatarUrl());
|
||||
embedBuilder.setTitle("Love Calculator");
|
||||
|
||||
embedBuilder.addField("\uD83D\uDC65 People",
|
||||
user1.getAsMention() + " & " + user2.getAsMention(),
|
||||
false);
|
||||
|
||||
embedBuilder.addField("❤️\u200D\uD83D\uDD25 Match",
|
||||
formattedAmount,
|
||||
false);
|
||||
|
||||
event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||
MessageEmbed embed = LoveCalculator.buildEmbed(event.getAuthor(), user1, user2);
|
||||
event.getChannel().sendMessageEmbeds(embed).queue();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.commands.base.LoveCalculator;
|
||||
import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||
|
||||
public class LoveCalculatorCommand extends SlashCommandImpl
|
||||
{
|
||||
@Override
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
|
||||
return Commands.slash("lovecalc",
|
||||
"Calculate how much two people love each other.")
|
||||
|
||||
.addOption(OptionType.MENTIONABLE,
|
||||
"first",
|
||||
"The first person to account for",
|
||||
true)
|
||||
|
||||
.addOption(OptionType.MENTIONABLE,
|
||||
"second",
|
||||
"The second person to account for",
|
||||
false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||
{
|
||||
User firstUser, secondUser;
|
||||
|
||||
OptionMapping firsUserArg = event.getOption("first");
|
||||
if(firsUserArg != null)
|
||||
{
|
||||
firstUser = firsUserArg.getAsUser();
|
||||
} else {
|
||||
event.reply("\uD83D\uDE22 I need to know who to check! Please mention them.")
|
||||
.setEphemeral(true)
|
||||
.queue();
|
||||
return;
|
||||
}
|
||||
|
||||
OptionMapping secondUserArg = event.getOption("second");
|
||||
if(secondUserArg != null)
|
||||
{
|
||||
secondUser = secondUserArg.getAsUser();
|
||||
} else {
|
||||
secondUser = event.getUser();
|
||||
}
|
||||
|
||||
MessageEmbed embed = LoveCalculator.buildEmbed(event.getUser(), firstUser, secondUser);
|
||||
event.replyEmbeds(embed).queue();
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@ package wtf.beatrice.hidekobot.util;
|
||||
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomUtil
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user