use of com.jagrosh.jagtag.Parser in project SkyBot by DuncteBot.
the class CommandManager method runCustomCommand.
private void runCustomCommand(ICommand cmd, String invoke, List<String> args, GuildMessageReceivedEvent event) {
final CustomCommand cusomCommand = (CustomCommand) cmd;
if (cusomCommand.getGuildId() != event.getGuild().getIdLong()) {
return;
}
try {
MDC.put("command.custom.message", cusomCommand.getMessage());
final Parser parser = CommandUtils.getParser(new CommandContext(invoke, args, event, variables));
final String message = parser.parse(cusomCommand.getMessage());
final MessageConfig.Builder messageBuilder = MessageConfig.Builder.fromEvent(event);
final DataObject object = parser.get("embed");
boolean hasContent = false;
if (!message.isEmpty()) {
messageBuilder.setMessage("\u200B" + message);
hasContent = true;
}
if (object != null) {
final JDAImpl jda = (JDAImpl) event.getJDA();
final EmbedBuilder embed = new EmbedBuilder(jda.getEntityBuilder().createMessageEmbed(object));
messageBuilder.addEmbed(true, embed);
hasContent = true;
}
if (hasContent) {
sendMsg(messageBuilder.build());
}
parser.clear();
} catch (Exception e) {
sendMsg(MessageConfig.Builder.fromEvent(event).setMessage("Error with parsing custom command: " + e.getMessage()).build());
Sentry.captureException(e);
}
}
use of com.jagrosh.jagtag.Parser in project SkyBot by duncte123.
the class CommandManager method runCustomCommand.
private void runCustomCommand(ICommand cmd, String invoke, List<String> args, GuildMessageReceivedEvent event) {
final CustomCommand cusomCommand = (CustomCommand) cmd;
if (cusomCommand.getGuildId() != event.getGuild().getIdLong()) {
return;
}
try {
MDC.put("command.custom.message", cusomCommand.getMessage());
final Parser parser = CommandUtils.getParser(new CommandContext(invoke, args, event, variables));
final String message = parser.parse(cusomCommand.getMessage());
final MessageConfig.Builder messageBuilder = MessageConfig.Builder.fromEvent(event);
final DataObject object = parser.get("embed");
boolean hasContent = false;
if (!message.isEmpty()) {
messageBuilder.setMessage("\u200B" + message);
hasContent = true;
}
if (object != null) {
final JDAImpl jda = (JDAImpl) event.getJDA();
final EmbedBuilder embed = new EmbedBuilder(jda.getEntityBuilder().createMessageEmbed(object));
messageBuilder.addEmbed(true, embed);
hasContent = true;
}
if (hasContent) {
sendMsg(messageBuilder.build());
}
parser.clear();
} catch (Exception e) {
sendMsg(MessageConfig.Builder.fromEvent(event).setMessage("Error with parsing custom command: " + e.getMessage()).build());
Sentry.captureException(e);
}
}
use of com.jagrosh.jagtag.Parser in project SkyBot by duncte123.
the class CommandUtils method parseJagTag.
public static String parseJagTag(CommandContext ctx, String content) {
final Parser parser = getParser(ctx);
final String parsed = parser.parse(content);
parser.clear();
return parsed;
}
use of com.jagrosh.jagtag.Parser in project SkyBot by DuncteBot.
the class CommandUtils method parseJagTag.
public static String parseJagTag(CommandContext ctx, String content) {
final Parser parser = getParser(ctx);
final String parsed = parser.parse(content);
parser.clear();
return parsed;
}
Aggregations