Search in sources :

Example 36 with EmbedBuilder

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

the class GuildMemberJoinListener method sendLogMessage.

private void sendLogMessage(final Member member) {
    member.getGuild().getTextChannelsByName("log", true).forEach(channel -> {
        final EmbedBuilder logBuilder = DiscordUtils.getDefaultEmbed(member);
        logBuilder.setThumbnail(member.getUser().getEffectiveAvatarUrl());
        logBuilder.appendDescription("Erstelldatum: " + member.getUser().getTimeCreated().format(DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm")) + "\n");
        logBuilder.appendDescription("Standard Avatar: " + (member.getUser().getAvatarUrl() == null) + "\n");
        channel.sendMessage(logBuilder.build()).queue();
    });
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 37 with EmbedBuilder

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

the class GuildMemberJoinListener method sendWelcomeMessage.

private void sendWelcomeMessage(final Member member) {
    if (System.getenv("BOTCHANNEL") == null) {
        return;
    }
    final boolean firstJoin = bot.getDatabase().getUserDao().getUser(member.getGuild().getId(), member.getId()) == null;
    final EmbedBuilder embedBuilder = DiscordUtils.getDefaultEmbed(member);
    embedBuilder.setColor(member.getGuild().getSelfMember().getColor());
    embedBuilder.setThumbnail(member.getUser().getEffectiveAvatarUrl());
    embedBuilder.appendDescription("Willkommen " + (firstJoin ? "" : "zurück ") + "auf c0debase " + member.getAsMention() + "\n");
    embedBuilder.appendDescription("— Weise dir eine Rolle mit !role zu\n");
    embedBuilder.appendDescription("— Schaue dir die Regeln in #rules an");
    member.getGuild().getTextChannelById(System.getenv("BOTCHANNEL")).sendMessage(embedBuilder.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 38 with EmbedBuilder

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

the class GuildMemberNickChangeListener method onGuildMemberUpdateNickname.

@Override
public void onGuildMemberUpdateNickname(@Nonnull GuildMemberUpdateNicknameEvent event) {
    event.getGuild().getTextChannelsByName("log", true).forEach(channel -> {
        final EmbedBuilder logBuilder = DiscordUtils.getDefaultEmbed(event.getMember());
        logBuilder.setTitle("Nickname geändert");
        logBuilder.appendDescription("Neuer Nickname:" + event.getNewNickname() + "\n");
        logBuilder.appendDescription("Alter Nickname: " + event.getOldNickname());
        channel.sendMessage(logBuilder.build()).queue();
    });
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 39 with EmbedBuilder

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

the class StatsCommand method execute.

@Override
public void execute(final String[] args, final Message message) {
    final JDA jda = message.getJDA();
    final long uptime = ManagementFactory.getRuntimeMXBean().getUptime();
    final EmbedBuilder embedBuilder = getEmbed(message.getGuild(), message.getAuthor());
    embedBuilder.addField("JDA Version", JDAInfo.VERSION, true);
    embedBuilder.addField("Ping", jda.getGatewayPing() + "ms", true);
    embedBuilder.addField("Uptime", String.valueOf(TimeUnit.MILLISECONDS.toDays(uptime) + "d " + TimeUnit.MILLISECONDS.toHours(uptime) % 24 + "h " + TimeUnit.MILLISECONDS.toMinutes(uptime) % 60 + "m " + TimeUnit.MILLISECONDS.toSeconds(uptime) % 60 + "s"), true);
    embedBuilder.addField("Commands", String.valueOf(bot.getCommandManager().getAvailableCommands().size()), true);
    embedBuilder.addField("Mitglieder", String.valueOf(jda.getGuilds().stream().mapToInt(Guild::getMemberCount).sum()), true);
    embedBuilder.addField("Java Version", System.getProperty("java.runtime.version").replace("+", "_"), true);
    embedBuilder.addField("Betriebssystem", ManagementFactory.getOperatingSystemMXBean().getName(), true);
    message.getChannel().sendMessage(embedBuilder.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) JDA(net.dv8tion.jda.api.JDA)

Example 40 with EmbedBuilder

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

the class YesNoCommand method execute.

@Override
public void execute(final String[] args, final Message message) {
    if (args.length > 0) {
        final StringJoiner stringJoiner = new StringJoiner(" ");
        for (int i = 0; i < args.length; i++) {
            stringJoiner.add(args[i]);
        }
        final boolean yn = Constants.RANDOM.nextBoolean();
        message.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Ja oder Nein?").setDescription("Deine Frage: " + stringJoiner.toString() + "\n\n" + "Meine Antwort: " + (yn ? "Ja" : "Nein") + "\n").setColor(yn ? Color.GREEN : Color.RED).setImage(yn ? yesGifs.get(Constants.RANDOM.nextInt(yesGifs.size())) : noGifs.get(Constants.RANDOM.nextInt(noGifs.size()))).build()).queue();
    } else {
        message.getTextChannel().sendMessage(getEmbed(message.getGuild(), message.getAuthor()).setDescription("!yn [Deine Frage]").build()).queue();
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) StringJoiner(java.util.StringJoiner)

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