Search in sources :

Example 41 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder 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();
    }
}
Also used : MessageHistory(net.dv8tion.jda.api.entities.MessageHistory) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Message(net.dv8tion.jda.api.entities.Message)

Example 42 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.

the class PingCommand method execute.

@Override
public void execute(final String[] args, final Message message) {
    final EmbedBuilder embedBuilder = getEmbed(message.getMember());
    embedBuilder.appendDescription(":stopwatch: " + message.getJDA().getGatewayPing() + " (Websocket)\n\n");
    embedBuilder.appendDescription(":stopwatch: " + message.getJDA().getRestPing().complete() + " (Rest)");
    message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 43 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.

the class RoleCommand method changeRole.

private void changeRole(final String args, final Message message) {
    final List<Role> addRoles = new ArrayList<>();
    final List<Role> removeRoles = new ArrayList<>();
    for (final String role : args.split(" ")) {
        if (isRoleAvailable(role, message.getGuild())) {
            addRolesToList(message.getMember(), role, addRoles, removeRoles);
        } else if (isRoleAvailable("Color-" + role, message.getGuild())) {
            addRolesToList(message.getMember(), "Color-" + role, addRoles, removeRoles);
        }
    }
    message.getGuild().modifyMemberRoles(message.getMember(), addRoles, removeRoles).queue(sucess -> {
        final EmbedBuilder embedBuilder = getEmbed(message.getGuild(), message.getAuthor());
        embedBuilder.setTitle("Rolle(n) geupdatet");
        embedBuilder.appendDescription("Du bist " + addRoles.size() + (addRoles.size() > 1 ? " Rollen " : " Rolle ") + "beigetreten\n");
        embedBuilder.appendDescription("Du hast " + removeRoles.size() + (removeRoles.size() == 1 ? " Rolle " : " Rollen ") + "verlassen");
        message.getTextChannel().sendMessage(embedBuilder.build()).queue();
    });
}
Also used : Role(net.dv8tion.jda.api.entities.Role) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) ArrayList(java.util.ArrayList)

Example 44 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.

the class AskCommand method execute.

@Override
public void execute(String[] args, Message message) {
    final EmbedBuilder embedBuilder = getEmbed(message.getGuild(), message.getAuthor());
    embedBuilder.setTitle("Wie man Fragen richtig stellt", "https://www.dontasktoask.com/");
    embedBuilder.appendDescription("Zur schnellen Problemlösung solltest Du folgende Tipps berücksichtigen: \n\n");
    embedBuilder.appendDescription("1. Eigeninitiative. Sprich, einfach mal das Internet benutzen.\n");
    embedBuilder.appendDescription("2. Red nicht lange drum herum, komm zum Punkt.\n");
    embedBuilder.appendDescription("3. Sei nicht sparsam und gib so viele Infos wie möglich.\n");
    embedBuilder.appendDescription("4. Schick Deinen Code ruhig mit.\n");
    embedBuilder.appendDescription("5. Lies Dir nochmal Deine Nachricht durch.\n\n");
    embedBuilder.appendDescription("[Mehr zum Thema findest Du hier.](https://gist.github.com/finreinhard/b842b690255bb80d929f8a5467d75597)");
    message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 45 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.

the class ColorCommand method execute.

@Override
public void execute(final String[] args, final Message message) {
    final EmbedBuilder embedBuilder = getEmbed(message.getMember());
    if (args.length > 0) {
        if (VALID_HEX_CODE.matcher(args[0].replace("#", "")).matches()) {
            embedBuilder.setTitle("Color-Code-Preview").setDescription("Farbcode Vorschau für: " + args[0]).setImage("https://dummyimage.com/250x250/" + args[0].replace("#", "") + "/" + args[0].replace("#", "") + ".png");
        } else {
            embedBuilder.setDescription("Kein Hex Code gefunden :hushed:");
        }
    } else {
        embedBuilder.setDescription("!color [code]");
    }
    message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Aggregations

EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)47 Member (net.dv8tion.jda.api.entities.Member)8 TimeUnit (java.util.concurrent.TimeUnit)7 Collectors (java.util.stream.Collectors)7 Message (net.dv8tion.jda.api.entities.Message)7 Context (net.kodehawa.mantarobot.core.modules.commands.base.Context)7 MantaroData (net.kodehawa.mantarobot.data.MantaroData)7 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)7 Color (java.awt.Color)6 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)6 MessageEmbed (net.dv8tion.jda.api.entities.MessageEmbed)6 Utils (net.kodehawa.mantarobot.utils.Utils)6 Subscribe (com.google.common.eventbus.Subscribe)5 List (java.util.List)5 Role (net.dv8tion.jda.api.entities.Role)5 CommandCategory (net.kodehawa.mantarobot.core.modules.commands.base.CommandCategory)5 HelpContent (net.kodehawa.mantarobot.core.modules.commands.help.HelpContent)5 I18nContext (net.kodehawa.mantarobot.core.modules.commands.i18n.I18nContext)5 LinkedList (java.util.LinkedList)4 Permission (net.dv8tion.jda.api.Permission)4