use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class JobCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Language lg = Translator.getLanguageFrom(message.getChannel());
Matcher m = getMatcher(message);
m.find();
// TODO
new BasicDiscordException("exception.basic.in_developpment");
}
return false;
}
use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class MonsterCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Matcher m = getMatcher(message);
Language lg = Translator.getLanguageFrom(message.getChannel());
m.find();
if (message.getChannel().getModifiedPermissions(ClientConfig.DISCORD().getOurUser()).contains(Permissions.USE_EXTERNAL_EMOJIS) && ClientConfig.DISCORD().getOurUser().getPermissionsForGuild(message.getGuild()).contains(Permissions.USE_EXTERNAL_EMOJIS)) {
String normalName = Normalizer.normalize(m.group(2).trim(), Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").toLowerCase();
String editedName = removeUselessWords(normalName);
BestMatcher matcher = new BestMatcher(normalName);
try {
matcher.evaluateAll(getListRequestableFrom(getSearchURL(lg, editedName), message, notFoundMonster));
if (matcher.isUnique()) {
// We have found it !
Embedded monster = Monster.getMonster(lg, Translator.getLabel(lg, "game.url") + matcher.getBest().getUrl());
if (m.group(1) != null)
Message.sendEmbed(message.getChannel(), monster.getMoreEmbedObject(lg));
else
Message.sendEmbed(message.getChannel(), monster.getEmbedObject(lg));
} else if (// Too much monsters
!matcher.isEmpty())
tooMuchMonsters.throwException(message, this, lg, matcher.getBests());
else
// empty
notFoundMonster.throwException(message, this, lg);
} catch (IOException e) {
ExceptionManager.manageIOException(e, message, this, lg, notFoundMonster);
}
return true;
} else
noExternalEmojiPermission.throwException(message, this, lg);
}
return false;
}
use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class PortalCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Matcher m = getMatcher(message);
Language lg = Translator.getLanguageFrom(message.getChannel());
m.find();
if (m.group(1) == null && m.group(5) == null) {
// No dimension precised
for (Portal pos : Guild.getGuild(message.getGuild()).getPortals()) Message.sendEmbed(message.getChannel(), pos.getEmbedObject(lg));
} else {
List<Portal> portals = new ArrayList<>();
if (m.group(1) != null)
portals = getPortal(m.group(1), Guild.getGuild(message.getGuild()));
if (portals.size() == 1) {
if (m.group(2) != null)
portals.get(0).setCoordonate(Position.parse("[" + m.group(3) + "," + m.group(4) + "]"), message.getAuthor().getDisplayName(message.getGuild()));
if (m.group(5) != null)
portals.get(0).setUtilisation(Integer.parseInt(m.group(5).replaceAll("\\s", "")), message.getAuthor().getDisplayName(message.getGuild()));
Message.sendEmbed(message.getChannel(), portals.get(0).getEmbedObject(lg));
} else if (portals.size() > 1)
tooMuchPortals.throwException(message, this, lg);
else
notFoundPortal.throwException(message, this, lg);
}
}
return false;
}
use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class ResourceCommand method request.
@Override
public boolean request(IMessage message) {
if (super.request(message)) {
Matcher m = getMatcher(message);
Language lg = Translator.getLanguageFrom(message.getChannel());
m.find();
String normalName = Normalizer.normalize(m.group(2).trim(), Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").toLowerCase();
BestMatcher matcher = new BestMatcher(normalName);
try {
for (TypeResource resource : TypeResource.values()) {
String[] names = resource.getNames(lg);
gatherData(message, matcher, names, normalName, resource, notFoundRsrc);
}
if (matcher.isEmpty())
for (SuperTypeResource type : SuperTypeResource.values()) matcher.evaluateAll(getListRequestableFrom(getSearchURL(type.getUrl(lg), normalName, null, lg), message, notFoundRsrc));
if (matcher.isUnique()) {
// We have found it !
Embedded resource = Resource.getResource(lg, Translator.getLabel(lg, "game.url") + matcher.getBest().getUrl());
if (m.group(1) != null)
Message.sendEmbed(message.getChannel(), resource.getMoreEmbedObject(lg));
else
Message.sendEmbed(message.getChannel(), resource.getEmbedObject(lg));
} else if (// Too much items
!matcher.isEmpty())
tooMuchRsrcs.throwException(message, this, lg, matcher.getBests());
else
// empty
notFoundRsrc.throwException(message, this, lg);
} catch (IOException e) {
ExceptionManager.manageIOException(e, message, this, lg, notFoundRsrc);
}
return true;
}
return false;
}
use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class Message method sendText.
public static void sendText(IChannel channel, String content) {
Language lg = Translator.getLanguageFrom(channel);
RequestBuffer.request(() -> {
try {
new MessageBuilder(ClientConfig.DISCORD()).withChannel(channel).withContent(content).build();
} catch (RateLimitException e) {
LoggerFactory.getLogger(Message.class).warn(e.getMessage(), e);
throw e;
} catch (DiscordException e) {
Reporter.report(e, channel.isPrivate() ? null : channel.getGuild(), channel);
LoggerFactory.getLogger(Message.class).error(e.getMessage(), e);
} catch (MissingPermissionsException e) {
LoggerFactory.getLogger(Message.class).warn(Constants.name + " n'a pas les permissions pour appliquer cette requĂȘte.");
new MissingPermissionDiscordException().throwException(channel, lg, e);
} catch (Exception e) {
Reporter.report(e, channel.isPrivate() ? null : channel.getGuild(), channel);
LoggerFactory.getLogger(Message.class).error(e.getMessage(), e);
}
return null;
});
}
Aggregations