use of net.dv8tion.jda.api.entities.MessageEmbed in project c0debaseBot by Biospheere.
the class MessageReceiveListener method checkMemeMessage.
/**
* @param message
* @return if the message has been deleted
*/
private boolean checkMemeMessage(final Message message) {
if (!message.getTextChannel().getName().contains("meme")) {
return false;
}
if (message.getTextChannel().getTopic() == null || !message.getTextChannel().getTopic().contains("test")) {
return false;
}
final boolean containsURL = StringUtils.containtsURL(message.getContentStripped());
final boolean containsAttachment = !message.getAttachments().isEmpty();
if (!containsURL && !containsAttachment) {
message.delete().queue(success -> {
final MessageEmbed messageEmbed = new EmbedBuilder().setDescription("Deine Nachricht wurde gelöscht da sie kein Bild/Video oder Link enthält.").setColor(message.getGuild().getSelfMember().getColor()).build();
message.getChannel().sendMessage(messageEmbed).delay(Duration.ofSeconds(10)).flatMap(Message::delete).queue();
});
return true;
}
return false;
}
use of net.dv8tion.jda.api.entities.MessageEmbed in project c0debaseBot by Biospheere.
the class LaTeXCommand method execute.
@Override
public void execute(final String[] args, final Message message) {
// Define the LaTeX expression
final String expression = String.join(" ", args).trim();
// Check of the expression is empty
if (expression.isEmpty()) {
final MessageEmbed embed = getEmbed(message.getGuild(), message.getAuthor()).setTitle("Fehler").setColor(Color.RED).setDescription("Die LaTeX expression darf nicht leer sein!").build();
message.getTextChannel().sendMessage(embed).queue();
return;
}
// Render the expression
final MessageEmbed embed = getEmbed(message.getGuild(), message.getAuthor()).setTitle("Rendert...").setColor(Color.YELLOW).setDescription("Die Expression wird gerendert...").build();
message.getTextChannel().sendMessage(embed).queue(msg -> {
// Retrieve the image URL
renderLaTeX(expression).whenComplete((imageURL, throwable) -> {
// Check if an error occurred
if (throwable != null) {
final MessageEmbed errorEmbed = getEmbed(message.getGuild(), message.getAuthor()).setTitle("Fehler").setColor(Color.RED).setDescription("`" + throwable.getMessage() + "`").build();
msg.editMessage(errorEmbed).queue();
return;
}
// Respond with the image
final MessageEmbed successEmbed = getEmbed(message.getGuild(), message.getAuthor()).setTitle("LaTeX-Expression").setColor(Color.GREEN).setImage(imageURL).build();
msg.editMessage(successEmbed).queue();
});
});
}
Aggregations