2022-12-19 01:36:43 +01:00
|
|
|
package wtf.beatrice.hidekobot.commands.message;
|
|
|
|
|
|
|
|
import net.dv8tion.jda.api.Permission;
|
|
|
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
2022-12-20 17:18:24 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2022-12-19 01:36:43 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2022-12-20 23:03:21 +01:00
|
|
|
import wtf.beatrice.hidekobot.commands.base.DiceRoll;
|
|
|
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
2022-12-20 17:05:59 +01:00
|
|
|
import wtf.beatrice.hidekobot.objects.commands.CommandCategory;
|
2022-12-19 01:36:43 +01:00
|
|
|
import wtf.beatrice.hidekobot.objects.commands.MessageCommand;
|
|
|
|
|
2022-12-24 14:48:17 +01:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2022-12-19 01:36:43 +01:00
|
|
|
|
|
|
|
public class DiceRollCommand implements MessageCommand
|
|
|
|
{
|
2022-12-20 17:05:59 +01:00
|
|
|
@Override
|
|
|
|
public LinkedList<String> getCommandLabels() {
|
|
|
|
return new LinkedList<>(Arrays.asList("diceroll", "droll", "roll"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public List<Permission> getPermissions() {
|
|
|
|
return null; // anyone can use it
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean passRawArgs() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-12-20 17:51:28 +01:00
|
|
|
@NotNull
|
|
|
|
@Override
|
2023-01-16 03:53:51 +01:00
|
|
|
public String getDescription()
|
|
|
|
{
|
|
|
|
return """
|
|
|
|
Roll dice. You can roll multiple dice at the same time.
|
|
|
|
Examples:
|
|
|
|
- `d8 10` to roll an 8-sided die 10 times.
|
|
|
|
- `d12 3 d5 10` to roll a 12-sided die 3 times, and then a 5-sided die 10 times.
|
|
|
|
- `30` to roll a standard 6-sided die 30 times.
|
|
|
|
- `d10` to roll a 10-sided die once.
|
|
|
|
""";
|
2022-12-20 17:51:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public String getUsage() {
|
|
|
|
return "[dice size] [rolls]";
|
|
|
|
}
|
|
|
|
|
2022-12-20 17:18:24 +01:00
|
|
|
@NotNull
|
2022-12-20 17:05:59 +01:00
|
|
|
@Override
|
|
|
|
public CommandCategory getCategory() {
|
|
|
|
return CommandCategory.FUN;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
|
|
|
{
|
|
|
|
|
2022-12-20 23:03:21 +01:00
|
|
|
MessageResponse response = DiceRoll.buildResponse(event.getAuthor(), args);
|
2022-12-20 17:05:59 +01:00
|
|
|
|
2022-12-21 02:51:23 +01:00
|
|
|
if(response.content() != null)
|
2022-12-19 01:36:43 +01:00
|
|
|
{
|
2022-12-21 02:51:23 +01:00
|
|
|
event.getMessage().reply(response.content()).queue();
|
|
|
|
} else if(response.embed() != null)
|
2022-12-20 17:05:59 +01:00
|
|
|
{
|
2022-12-21 02:51:23 +01:00
|
|
|
event.getMessage().replyEmbeds(response.embed()).queue();
|
2022-12-20 17:05:59 +01:00
|
|
|
}
|
2022-12-19 17:30:47 +01:00
|
|
|
|
2022-12-20 17:05:59 +01:00
|
|
|
}
|
2022-12-19 01:36:43 +01:00
|
|
|
|
|
|
|
}
|