Search in sources :

Example 81 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project MantaroBot by Mantaro.

the class ImageCmds method nsfwCheck.

private static boolean nsfwCheck(GuildMessageReceivedEvent event, boolean isGlobal, boolean sendMessage) {
    if (event.getChannel().isNSFW())
        return true;
    String nsfwChannel = MantaroData.db().getGuild(event.getGuild()).getData().getGuildUnsafeChannels().stream().filter(channel -> channel.equals(event.getChannel().getId())).findFirst().orElse(null);
    String rating1 = rating == null ? "s" : rating;
    boolean trigger = !isGlobal ? ((rating1.equals("s") || (nsfwChannel == null)) ? rating1.equals("s") : nsfwChannel.equals(event.getChannel().getId())) : nsfwChannel != null && nsfwChannel.equals(event.getChannel().getId());
    if (!trigger) {
        if (sendMessage)
            event.getChannel().sendMessage(new EmbedBuilder().setDescription("Not on a NSFW channel. Cannot send lewd images.\n" + "**Reminder:** You can set this channel as NSFW by doing `~>opts nsfw toggle` if you are an administrator on this server.").build()).queue();
        return false;
    }
    return true;
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Example 82 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class UserProfile method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    User toGet;
    List<User> mentionedUsers = message.getMentionedUsers();
    if (mentionedUsers.size() == 0)
        toGet = user;
    else
        toGet = mentionedUsers.get(0);
    Profile profile = Profile.get(toGet);
    EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
    builder.setAuthor("{0}'s profile".replace("{0}", toGet.getName()), getShard().url, toGet.getAvatarUrl());
    Marriage marriage = Marry.getMarriage(toGet);
    if (marriage == null)
        builder.addField("Married to", "No one :(", true);
    else {
        builder.addField("Married to", UserUtils.getNameWithDiscriminator(marriage.getUser_one().equals(toGet.getId()) ? marriage.getUser_two() : marriage.getUser_one()), true);
    }
    builder.addField("Balance", RPGUtils.formatMoney(profile.getMoney()), true);
    builder.addField("Items", "Coming soon!", true);
    sendEmbed(builder, channel, user);
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) User(net.dv8tion.jda.core.entities.User) Marriage(tk.ardentbot.rethink.models.Marriage) Profile(tk.ardentbot.utils.rpg.profiles.Profile)

Example 83 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class NSFW method setupSubcommands.

@Override
public void setupSubcommands() throws Exception {
    subcommands.add(new Subcommand("Set whether people can send NSFW channels in all channels", "alloweverywhere [true/false]", "alloweverywhere") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            if (guild.getMember(user).hasPermission(Permission.MANAGE_SERVER)) {
                if (args.length == 3) {
                    try {
                        boolean allowEverywhere = Boolean.parseBoolean(args[2]);
                        getSettings(guild);
                        if (allowEverywhere)
                            sendTranslatedMessage("You can now use NSFW commands in all channels", channel, user);
                        else
                            sendTranslatedMessage("You can now use NSFW commands only in specified channels", channel, user);
                        r.table("nsfw_settings").get(guild.getId()).update(r.hashMap("global", allowEverywhere)).run(connection);
                    } catch (Exception e) {
                        sendTranslatedMessage("You need to specify true or false", channel, user);
                    }
                } else
                    sendTranslatedMessage("Invalid arguments ¯\\_(ツ)_/¯", channel, user);
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
    subcommands.add(new Subcommand("Set whether you need a role called NSFW to send NSFW commands", "neednsfwrole [true/false]", "neednsfwrole") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            if (guild.getMember(user).hasPermission(Permission.MANAGE_SERVER)) {
                if (args.length == 3) {
                    try {
                        boolean needs = Boolean.parseBoolean(args[2]);
                        getSettings(guild);
                        if (needs)
                            sendTranslatedMessage("You now need the NSFW role to send NSFW commands", channel, user);
                        else
                            sendTranslatedMessage("Anyone can now send NSFW commands", channel, user);
                        r.table("nsfw_settings").get(guild.getId()).update(r.hashMap("needNsfwRole", needs)).run(connection);
                    } catch (Exception e) {
                        sendTranslatedMessage("You need to specify true or false", channel, user);
                    }
                } else
                    sendTranslatedMessage("Invalid arguments ¯\\_(ツ)_/¯", channel, user);
            } else
                sendTranslatedMessage("You need the Manage Server permission to use this command", channel, user);
        }
    });
    subcommands.add(new Subcommand("View the current NSFW settings for your server", "settings", "settings") {

        @Override
        public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
            String nsfwSettings = "NSFW Settings";
            NSFWSettings settings = getSettings(guild);
            EmbedBuilder embedBuilder = MessageUtils.getDefaultEmbed(user);
            embedBuilder.setAuthor(nsfwSettings, getShard().url, getShard().bot.getAvatarUrl());
            StringBuilder description = new StringBuilder();
            description.append("**" + nsfwSettings + "**");
            description.append("\n\nAble to use NSFW commands in all channels: " + settings.isGlobal());
            description.append("\n\nNeed the NSFW role: " + settings.isNeedNsfwRole());
            if (!settings.isGlobal()) {
                description.append("\n\nCan only use these command in discord NSFFW channels");
            }
            embedBuilder.setDescription(description.toString());
            sendEmbed(embedBuilder, channel, user);
        }
    });
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) NSFWSettings(tk.ardentbot.rethink.models.NSFWSettings) Subcommand(tk.ardentbot.core.executor.Subcommand)

Example 84 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class TrackScheduler method onTrackStart.

@Override
public void onTrackStart(AudioPlayer player, AudioTrack track) {
    if (manager.isShouldAnnounce()) {
        if (manager.getLastAnnouncementId() != null) {
            try {
                manager.getChannel().getMessageById(manager.getLastAnnouncementId()).queue(message -> message.delete().queue());
            } catch (Exception ignored) {
            }
        }
        User me = manager.getChannel().getGuild().getSelfMember().getUser();
        AudioTrackInfo info = track.getInfo();
        EmbedBuilder builder = MessageUtils.getDefaultEmbed(me);
        builder.setAuthor("Now playing " + info.title, "https://ardentbot.tk", "https://s-media-cache-ak0.pinimg" + ".com/736x/69/96/5c/69965c2849ec9b7148a5547ce6714735.jpg");
        builder.setThumbnail("https://s-media-cache-ak0.pinimg.com/736x/69/96/5c/69965c2849ec9b7148a5547ce6714735.jpg");
        builder.addField("Title", info.title, true).addField("Author", info.author, true).addField("Duration", Music.getDuration(track), true).addField("URL", info.uri, true).addField("Is Stream", String.valueOf(info.isStream), true);
        Message m = GuildUtils.getShard(manager.getChannel().getJDA()).help.sendEmbed(builder, manager.getChannel(), me);
        manager.setLastAnnouncementId(m.getId());
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) User(net.dv8tion.jda.core.entities.User) Message(net.dv8tion.jda.core.entities.Message) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) BotException(tk.ardentbot.core.misc.logging.BotException)

Example 85 with EmbedBuilder

use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.

the class Command method getHelp.

private EmbedBuilder getHelp(Guild guild, User author) throws Exception {
    Shard shard = GuildUtils.getShard(guild);
    EmbedBuilder embedBuilder = MessageUtils.getDefaultEmbed(author);
    String name = getName();
    name = name.substring(0, 1).toUpperCase() + name.substring(1);
    embedBuilder.setAuthor(name, shard.url, shard.bot.getAvatarUrl());
    StringBuilder description = new StringBuilder();
    description.append(getDescription());
    if (subcommands.size() > 0) {
        description.append("\n\n**Subcommands**\n");
        for (Subcommand subcommand : subcommands) {
            description.append(subcommand.getSyntax() + ": *" + subcommand.getDescription() + "*\n");
        }
        description.append("\n**Example**:");
        description.append("\n/" + name.toLowerCase() + " " + subcommands.get(0).getSyntax());
    }
    if (aliases != null && aliases.length > 0) {
        description.append("\n**Aliases**:\n");
        description.append(MessageUtils.listWithCommas(Arrays.asList(aliases)));
    }
    embedBuilder.setDescription(description.toString());
    return embedBuilder;
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) Shard(tk.ardentbot.main.Shard)

Aggregations

EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)128 Message (net.dv8tion.jda.core.entities.Message)26 List (java.util.List)24 ArrayList (java.util.ArrayList)22 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)22 User (net.dv8tion.jda.core.entities.User)20 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)20 Collectors (java.util.stream.Collectors)19 MantaroData (net.kodehawa.mantarobot.data.MantaroData)19 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)17 Utils (net.kodehawa.mantarobot.utils.Utils)17 TimeUnit (java.util.concurrent.TimeUnit)16 Permission (net.dv8tion.jda.core.Permission)15 Subscribe (com.google.common.eventbus.Subscribe)13 Color (java.awt.Color)13 Guild (net.dv8tion.jda.core.entities.Guild)12 TextChannel (net.dv8tion.jda.core.entities.TextChannel)12 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)12 DiscordUtils (net.kodehawa.mantarobot.utils.DiscordUtils)12 java.awt (java.awt)11