use of net.dv8tion.jda.api.exceptions.InsufficientPermissionException in project MantaroBot by Mantaro.
the class Character method onStart.
@Override
public boolean onStart(GameLobby lobby) {
final I18nContext languageContext = lobby.getLanguageContext();
try {
var data = JsonDataManager.fromJson(APIUtils.getFrom("/mantaroapi/bot/character"), AnimeGameData.class);
characterNameL = new ArrayList<>();
characterName = data.getName();
var imageUrl = data.getImage();
// Allow for replying with only the first name of the character.
if (characterName.contains(" ")) {
characterNameL.add(characterName.split(" ")[0]);
}
characterNameL.add(characterName);
sendEmbedImage(lobby.getChannel(), imageUrl, eb -> eb.setAuthor(languageContext.get("commands.game.character_start"), null, lobby.getEvent().getAuthor().getEffectiveAvatarUrl()).setFooter(languageContext.get("commands.game.end_footer"), null)).queue(success -> lobby.setGameLoaded(true));
return true;
} catch (JsonProcessingException ex) {
ex.printStackTrace();
lobby.getChannel().sendMessageFormat(languageContext.get("commands.game.character_load_error"), EmoteReference.WARNING, characterName).queue();
return false;
} catch (InsufficientPermissionException ex) {
lobby.getChannel().sendMessageFormat(languageContext.get("commands.game.error_missing_permissions"), EmoteReference.ERROR).queue();
return false;
} catch (Exception e) {
lobby.getChannel().sendMessageFormat(languageContext.get("commands.game.error"), EmoteReference.ERROR).queue();
log.warn("Exception while setting up a game", e);
return false;
}
}
Aggregations