use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class RandomPickCommand method process.
@Override
public void process(GuildCommandEvent e) {
Member memberr = e.getMember();
long member = memberr.getIdLong();
TextChannel tco = e.getChannel();
Draft d = Draft.getDraftByMember(member, tco);
if (d == null) {
e.getChannel().sendMessage("Du Kek der Command funktioniert nur in einem Draft xD").queue();
return;
}
String msg = e.getMessage().getContentDisplay();
Tierlist tierlist = d.getTierlist();
ArgumentManager args = e.getArguments();
String tier = tierlist.order.stream().filter(s -> args.getText("tier").equalsIgnoreCase(s)).findFirst().orElse("");
if (tier.equals("")) {
tco.sendMessage("Das ist kein Tier!").queue();
return;
}
if (!d.tc.getId().equals(tco.getId()))
return;
if (d.isNotCurrent(member)) {
tco.sendMessage(d.getMention(member) + " Du bist nicht dran!").queue();
return;
}
long mem = d.current;
JSONObject json = getEmolgaJSON();
// JSONObject league = json.getJSONObject("drafts").getJSONObject(d.name);
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
/*if (asl.has("allowed")) {
JSONObject allowed = asl.getJSONObject("allowed");
if (allowed.has(member.getId())) {
mem = d.tc.getGuild().retrieveMemberById(allowed.getString(member.getId())).complete();
} else mem = member;
} else mem = member;*/
ArrayList<String> list = new ArrayList<>(tierlist.tierlist.get(tier));
Collections.shuffle(list);
Predicate<String> typecheck;
if (args.has("type")) {
Translation type = args.getTranslation("type");
typecheck = str -> getDataJSON().getJSONObject(getSDName(str)).getJSONArray("types").toList().contains(type.getTranslation());
} else {
typecheck = str -> true;
}
PickCommand.exec(tco, "!pick " + list.stream().filter(str -> !d.isPicked(str) && !d.hasInAnotherForm(mem, str) && (!d.hasMega(mem) || !str.startsWith("M-")) && typecheck.test(str)).map(String::trim).findFirst().orElse(""), memberr, true);
}
use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class ShowdownPokeFansCommand method process.
@Override
public void process(GuildCommandEvent e) {
JSONArray tosend = new JSONArray();
// for (String id : ids) {
String paste = e.getArguments().getText("paste");
JSONArray oneUser = new JSONArray();
oneUser.put("HierDenNamenÄndern");
oneUser.put("HierDieLigaÄndern");
List<String> pmons = new LinkedList<>();
for (String s : paste.split("\n")) {
if (s.trim().length() == 0)
continue;
if (s.contains(":") && !s.contains("Type: Null"))
continue;
logger.info("s = " + s);
pmons.add(s.trim());
}
JSONArray mons = new JSONArray();
logger.info("pmons = " + pmons);
pmons.stream().sorted(Comparator.comparing(str -> getDataJSON().getJSONObject(toSDName((String) str)).getJSONObject("baseStats").getInt("spe")).reversed()).map(s -> {
String[] split = s.split("-");
return getGerNameNoCheck(split[0]) + (split.length > 1 ? "-" + split[1] : "");
}).map(str -> str.replace("Boreos-T", "Boreos Tiergeistform").replace("Voltolos-T", "Voltolos Tiergeistform").replace("Demeteros-T", "Demeteros Tiergeistform").replace("Boreos-I", "Boreos Inkarnationsform").replace("Voltolos-I", "Voltolos Inkarnationsform").replace("Demeteros-I", "Demeteros Inkarnationsform").replace("Wolwerock-Tag", "Wolwerock Tagform").replace("Wolwerock-Nacht", "Wolwerock Nachtform").replace("Wolwerock-Zw", "Wolwerock Zwielichtform").replace("Shaymin", "Shaymin Landform").replace("Durengard", "Durengard Schildform").replace("Pumpdjinn", "Pumpdjinn XL").replace("M-", "Mega-").replace("A-", "Alola-").replace("G-", "Galar-")).forEach(mons::put);
oneUser.put(mons);
tosend.put(oneUser);
// }
e.reply(tosend.toString());
}
use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class FinishDraftCommand method process.
@Override
public void process(GuildCommandEvent e) {
String msg = e.getMsg();
TextChannel tco = e.getChannel();
Member memberr = e.getMember();
long member = memberr.getIdLong();
Draft d = Draft.getDraftByMember(member, tco);
if (d == null) {
// tco.sendMessage(member.getAsMention() + " Du bist in keinem Draft drin!").queue();
return;
}
JSONObject league = getEmolgaJSON().getJSONObject("drafts").getJSONObject(d.name);
if (!d.tc.getId().equals(tco.getId()))
return;
if (d.isNotCurrent(member)) {
tco.sendMessage(d.getMention(member) + " Du bist nicht dran!").queue();
return;
}
long mem = d.current;
int round = d.round;
if (e.getGuild().getIdLong() == Constants.NDSID && d.picks.get(mem).size() < 15) {
e.reply("Du hast noch keine 15 Pokemon!");
return;
}
/*if (round < 12) {
e.reply("Du hast noch nicht 11 Pokemon!");
return;
}*/
e.reply("Du hast den Draft für dich beendet!");
d.order.values().forEach(l -> l.removeIf(me -> me == mem));
league.put("finished", league.optString("finished") + mem + ",");
d.cooldown.cancel(false);
if (d.order.get(d.round).size() == 0) {
if (d.round == d.getTierlist().rounds) {
tco.sendMessage("Der Draft ist vorbei!").queue();
d.ended = true;
// wooloodoc(tierlist, pokemon, d, mem, needed, null, num, round);
saveEmolgaJSON();
Draft.drafts.remove(d);
return;
}
d.round++;
if (d.order.get(d.round).size() == 0) {
e.reply("Da alle bereits ihre Drafts beendet haben, ist der Draft vorbei!");
saveEmolgaJSON();
return;
}
d.tc.sendMessage("Runde " + d.round + "!").queue();
league.put("round", d.round);
}
d.current = d.order.get(d.round).remove(0);
league.put("current", d.current);
d.cooldown.cancel(false);
league.getJSONObject("picks").put(d.current, d.getTeamAsArray(d.current));
if (d.isPointBased)
// tco.sendMessage(getMention(current) + " (<@&" + asl.getLongList("roleids").get(getIndex(current.getIdLong())) + ">) ist dran! (" + points.get(current.getIdLong()) + " mögliche Punkte)").queue();
tco.sendMessage(d.getMention(d.current) + " ist dran! (" + d.points.get(d.current) + " mögliche Punkte)").queue();
else
tco.sendMessage(d.getMention(d.current) + " ist dran! (Mögliche Tiers: " + d.getPossibleTiersAsString(d.current) + ")").queue();
long delay = calculateDraftTimer();
league.put("cooldown", System.currentTimeMillis() + delay);
d.cooldown = d.scheduler.schedule((Runnable) d::timer, delay, TimeUnit.MILLISECONDS);
saveEmolgaJSON();
}
use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class SlashListener method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent e) {
Command command = Command.byName(e.getName());
User u = e.getUser();
TextChannel tco = e.getTextChannel();
try {
new GuildCommandEvent(command, e);
} catch (Command.MissingArgumentException ex) {
Command.ArgumentManagerTemplate.Argument arg = ex.getArgument();
if (arg.hasCustomErrorMessage())
e.reply(arg.getCustomErrorMessage()).queue();
else {
e.reply("Das benötigte Argument `" + arg.getName() + "`, was eigentlich " + buildEnumeration(arg.getType().getName()) + " sein müsste, ist nicht vorhanden!\n" + "Nähere Informationen über die richtige Syntax für den Command erhältst du unter `e!help " + command.getName() + "`.").queue();
}
if (u.getIdLong() != FLOID) {
sendToMe("MissingArgument " + tco.getAsMention() + " Server: " + tco.getGuild().getName());
}
} catch (Exception ex) {
ex.printStackTrace();
e.getHook().sendMessage("Es ist ein Fehler beim Ausführen des Commands aufgetreten!\nWenn du denkst, dass dies ein interner Fehler beim Bot ist, melde dich bitte bei Flo/TecToast.\n" + command.getHelp(e.getGuild()) + (u.getIdLong() == FLOID ? "\nJa Flo, du sollst dich auch bei ihm melden du Kek! :^)" : "")).queue();
}
}
use of de.tectoast.emolga.commands.GuildCommandEvent in project Emolga by TecToast.
the class ListmembersCommand method process.
@Override
public void process(GuildCommandEvent e) {
Message m = e.getMessage();
TextChannel tco = e.getChannel();
Member member = e.getMember();
ArgumentManager args = e.getArguments();
Role r = e.getJDA().getRoleById(args.getID("role"));
/*if (m.getMentionedRoles().size() == 0) {
if (m.getContentDisplay().split(" ").length == 2) {
try {
r = e.getGuild().getRoleById(m.getContentDisplay().split(" ")[1]);
} catch (Exception ex) {
tco.sendMessage(member.getAsMention() + " Du musst eine Rolle angeben!").queue();
return;
}
} else {
tco.sendMessage(member.getAsMention() + " Du musst eine Rolle angeben!").queue();
return;
}
} else
r = m.getMentionedRoles().get(0);*/
tco.getGuild().findMembers(mem -> mem.getRoles().contains(r)).onSuccess(members -> {
StringBuilder s = new StringBuilder();
for (Member mem : members) {
s.append(mem.getEffectiveName()).append("\n");
}
if (s.toString().equals("")) {
tco.sendMessage("Kein Member hat die Rolle " + r.getName() + "!").queue();
return;
}
s.append("Insgesamt: ").append(members.size());
tco.sendMessage("User mit der Rolle " + r.getName() + ":\n" + s).queue();
}).onError(t -> {
t.printStackTrace();
tco.sendMessage("Es ist ein Fehler beim Laden der Member aufgetreten!").queue();
});
}
Aggregations