!feat: moved poll command to Botendo, since it fix more

chore: bumped version
This commit is contained in:
limited_dev 2022-11-07 15:01:57 +01:00
parent ecea872b25
commit 61e71e4dc4
4 changed files with 1 additions and 109 deletions

View file

@ -5,7 +5,7 @@ plugins {
}
group = "de.limited_dev"
version = "v1.5.2"
version = "v1.5.3"
var splatoonPatchBased = "1.2.1"
repositories {

View file

@ -4,7 +4,6 @@ import de.limited_dev.lil_judd.commands.jdacommands.management.RemoveFeatureComm
import de.limited_dev.lil_judd.commands.jdacommands.management.SetupFeatureCommand;
import de.limited_dev.lil_judd.commands.jdacommands.util.InfoCommand;
import de.limited_dev.lil_judd.commands.jdacommands.util.PingCommand;
import de.limited_dev.lil_judd.commands.jdacommands.util.PollCommand;
import de.limited_dev.lil_judd.commands.jdacommands.util.TranslateMapCommand;
import de.limited_dev.lil_judd.commands.jdacommands.weapons.RandomWeaponCommand;
import de.limited_dev.lil_judd.commands.jdacommands.weapons.WeaponInfoCommand;
@ -28,7 +27,6 @@ public class JDACommandManager {
commands.add(new TranslateMapCommand());
commands.add(new WeaponInfoCommand());
commands.add(new RandomWeaponCommand());
commands.add(new PollCommand());
}
public static List<JDACommand> getCommands() {

View file

@ -1,93 +0,0 @@
package de.limited_dev.lil_judd.commands.jdacommands.util;
import de.limited_dev.lil_judd.commands.jdacommands.components.JDACommand;
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class PollCommand extends JDACommand {
public PollCommand() {
super("poll");
}
@Override
public void onSlashCommand(SlashCommandInteractionEvent event) {
Guild g = event.getGuild();
String caption = event.getOption("caption").getAsString();
List<String> voteOptions = new ArrayList<>();
String content = "";
int index = 0;
for (String s : optionNames) {
OptionMapping o = event.getOption(s);
if (o == null)
continue;
voteOptions.add(o.getAsString());
content += emojiToSelection2.get(index + 1) + " - " + o.getAsString() + "\n";
++index;
}
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Poll was created", "You can view it below.");
MessageEmbed eb = EmbeddedMessageHelper.getEmbeddedMessageAutomated(true, "Poll", caption + "\n\n" + content, null, true).build();
event.getChannel().sendMessageEmbeds(eb).queue(message -> addReactions(message, voteOptions));
}
private void addReactions(Message msg, List<String> voteOption) {
Thread thr = new Thread() {
@Override
public void run() {
for (int i = 0; i < voteOption.size(); ++i) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
msg.addReaction(Emoji.fromUnicode(emojiToSelection1.get(i + 1))).queue();
}
Thread.currentThread().interrupt();
}
};
thr.start();
}
private static final List<String> optionNames = List.of("option1", "option2", "option3", "option4", "option5", "option6", "option7", "option8", "option9", "option10");
private static final HashMap<Integer, String> emojiToSelection1 = new HashMap<>() {{
put(1, "1");
put(2, "2");
put(3, "3");
put(4, "4");
put(5, "5");
put(6, "6");
put(7, "7");
put(8, "8");
put(9, "9");
put(10, "🔟");
}};
private static final HashMap<Integer, String> emojiToSelection2 = new HashMap<>() {{
put(1, ":one:");
put(2, ":two:");
put(3, ":three:");
put(4, ":four:");
put(5, ":five:");
put(6, ":six:");
put(7, ":seven:");
put(8, ":eight:");
put(9, ":nine:");
put(10, ":keycap_ten:");
}};
}

View file

@ -33,19 +33,6 @@ public class SlashCommandRegister {
.addOptions(new OptionData(OptionType.STRING, "message", "Message content", true)),
Commands.slash("scriminfo", "Show info about the scrim system."),
*/
Commands.slash("poll", "Create a pol")
.addOptions(new OptionData(OptionType.STRING, "caption", "Caption the poll", true))
.addOptions(new OptionData(OptionType.STRING, "option1", "The 1st option", true))
.addOptions(new OptionData(OptionType.STRING, "option2", "The 2nd option", true))
.addOptions(new OptionData(OptionType.STRING, "option3", "The 3rd option"))
.addOptions(new OptionData(OptionType.STRING, "option4", "The 4th option"))
.addOptions(new OptionData(OptionType.STRING, "option5", "The 5th option"))
.addOptions(new OptionData(OptionType.STRING, "option6", "The 6th option"))
.addOptions(new OptionData(OptionType.STRING, "option7", "The 7th option"))
.addOptions(new OptionData(OptionType.STRING, "option8", "The 8th option"))
.addOptions(new OptionData(OptionType.STRING, "option9", "The 9th option"))
.addOptions(new OptionData(OptionType.STRING, "option10", "The 10th option"))
,
Commands.slash("translatemap", "Translate a Map from English to German or vice versa")
.addOptions(new OptionData(OptionType.STRING, "map", "Map Name", true)),
Commands.slash("weaponinfo", "Get infos about a weapon")