use of net.dv8tion.jda.api.entities.MessageHistory in project c0debaseBot by Biospheere.
the class ClearCommand method execute.
@Override
public void execute(final String[] args, final Message message) {
if (args.length == 0) {
final EmbedBuilder embedBuilder = getEmbed(message.getMember());
embedBuilder.appendDescription("!clear <Amount>");
message.getTextChannel().sendMessage(embedBuilder.build()).queue();
} else {
int i = 0;
try {
i = Integer.valueOf(args[0]);
} catch (NumberFormatException ex) {
ex.printStackTrace();
}
final MessageHistory history = new MessageHistory(message.getTextChannel());
final List<Message> messages = history.retrievePast(i + 1).complete();
message.getTextChannel().deleteMessages(messages).queue();
final EmbedBuilder embedBuilder = DiscordUtils.getDefaultEmbed(message.getMember());
embedBuilder.setColor(message.getGuild().getSelfMember().getColor());
embedBuilder.appendDescription("Es wurden **" + (i) + "** Nachrichten gelöscht");
message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
}
Aggregations