Search in sources :

Example 36 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project de-DiscordBot by DACH-Discord.

the class UserLog method userLeaveNotify.

private void userLeaveNotify(final IUser user) {
    final EmbedBuilder embedBuilder = new EmbedBuilder();
    final DateTimeFormatter timeStampFormatter = DateTimeFormatter.ofPattern("dd.MM. | HH:mm");
    embedBuilder.withThumbnail(user.getAvatarURL());
    embedBuilder.appendField(":x: Nutzer hat den Server verlassen!", "**Name:** " + user.getName() + '#' + user.getDiscriminator() + '\n' + "**ID:** " + user.getStringID(), false);
    embedBuilder.withFooterText(LocalDateTime.now().format(timeStampFormatter));
    embedBuilder.withColor(new Color(221, 46, 68));
    final EmbedObject embedObject = embedBuilder.build();
    Util.sendEmbed(userLogChannel, embedObject);
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) DateTimeFormatter(java.time.format.DateTimeFormatter) EmbedObject(sx.blah.discord.api.internal.json.objects.EmbedObject)

Example 37 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project de-DiscordBot by DACH-Discord.

the class UserLog method userBanNotify.

private void userBanNotify(final IUser user) {
    final EmbedBuilder embedBuilder = new EmbedBuilder();
    final DateTimeFormatter timeStampFormatter = DateTimeFormatter.ofPattern("dd.MM. | HH:mm");
    embedBuilder.withThumbnail(user.getAvatarURL());
    embedBuilder.appendField(":hammer: Nutzer gebannt!", "**Name:** " + user.getName() + '#' + user.getDiscriminator() + '\n' + "**ID:** " + user.getStringID(), false);
    embedBuilder.withFooterText(LocalDateTime.now().format(timeStampFormatter));
    final EmbedObject embedObject = embedBuilder.build();
    Util.sendEmbed(userLogChannel, embedObject);
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) DateTimeFormatter(java.time.format.DateTimeFormatter) EmbedObject(sx.blah.discord.api.internal.json.objects.EmbedObject)

Example 38 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class QueueCommand method queueCommand.

@BotCommand(command = "queue", module = MusicModule.MODULE, description = "Show the currently queued songs", usage = "Queue", allowedChannels = "music", args = 1)
public static void queueCommand(CommandContext cc) throws CommandException {
    List<AudioTrack> queue = MusicModule.getVoiceManager().getQueue(cc.getGuild());
    AudioTrack nowPlaying = MusicModule.getVoiceManager().getNowPlaying(cc.getGuild());
    if (nowPlaying == null)
        throw new CommandStateException("The queue is empty! Play something with !Play");
    final long totalTime = MusicModule.getVoiceManager().getQueue(cc.getGuild()).stream().map(AudioTrack::getDuration).reduce(0L, (x, y) -> x + y) + MusicModule.getVoiceManager().getNowPlaying(cc.getGuild()).getDuration();
    EmbedBuilder embed = new EmbedBuilder();
    embed.withTitle(":clock1030: Queue Length");
    embed.withDescription(TimeUtil.getFormattedTime(totalTime));
    embed.withColor(MusicModule.EMBED_COLOR);
    StringBuilder songs = new StringBuilder();
    int i = 2;
    songs.append("***1. ").append(nowPlaying.getInfo().title).append("***").append('\n');
    for (AudioTrack audioTrack : queue) {
        if ((songs.length() + audioTrack.getInfo().title.length()) >= 975 && (i - 1) < queue.size()) {
            songs.append("\n");
            songs.append("    ***... and ").append(queue.size() - (i - 1)).append(" more***");
            break;
        }
        songs.append(i++).append(". ").append(audioTrack.getInfo().title).append('\n');
    }
    embed.appendField(":arrow_forward: Now Playing", songs.length() > 1 ? songs.toString() : "\n", true);
    cc.replyWith(embed.build());
}
Also used : CommandException(com.discordbolt.api.command.exceptions.CommandException) EmbedBuilder(sx.blah.discord.util.EmbedBuilder) List(java.util.List) TimeUtil(com.discordbolt.boltbot.utils.TimeUtil) MusicModule(com.discordbolt.boltbot.modules.music.MusicModule) CommandArgumentException(com.discordbolt.api.command.exceptions.CommandArgumentException) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) CommandContext(com.discordbolt.api.command.CommandContext) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException) BotCommand(com.discordbolt.api.command.BotCommand) EmbedBuilder(sx.blah.discord.util.EmbedBuilder) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) BotCommand(com.discordbolt.api.command.BotCommand)

Example 39 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class Playlist method toEmbed.

public EmbedObject toEmbed() {
    EmbedBuilder embed = new EmbedBuilder();
    embed.withColor(MusicModule.EMBED_COLOR);
    embed.withAuthorName(getTitle());
    embed.withAuthorIcon(getOwner().getAvatarURL());
    embed.withTitle("Songs");
    StringBuilder songs = new StringBuilder();
    int index = 1;
    for (String songID : getSongIDs()) {
        songs.append(index).append(". ").append(getSongTitle(songID).replace("*", " ").replace("_", "").replace("~", "")).append('\n');
        index++;
    }
    songs.setLength(2048);
    embed.withDesc(songs.toString());
    if (getContributors().size() > 0) {
        StringBuilder contributors = new StringBuilder();
        for (IUser c : getContributors()) {
            contributors.append("\n").append(c.getName());
        }
        embed.appendField("Contributors", contributors.toString() + " ", false);
    }
    embed.withFooterText("Playlist by " + getOwner().getName());
    return embed.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) IUser(sx.blah.discord.handle.obj.IUser)

Example 40 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class SelfPost method toEmbed.

@Override
public EmbedObject toEmbed() {
    EmbedBuilder embed = new EmbedBuilder();
    embed.withColor(EMBED_COLOR);
    // Embed Title
    embed.withAuthorName(EmbedUtil.limitString(EmbedUtil.AUTHOR_NAME_MAX_LENGTH, getTitle()));
    embed.withAuthorUrl("https://www.reddit.com/r/" + getSubreddit() + "/comments/" + getId());
    // Embed Text
    embed.withDesc(EmbedUtil.limitString(EmbedUtil.DESCRIPTION_MAX_LENGTH, getSelfText()));
    // Post info
    embed.appendField(":pencil2: Author", EmbedUtil.limitString(EmbedUtil.FIELD_VALUE_MAX_LENGTH, getAuthor()), true);
    embed.appendField(":arrow_up: Upvotes", String.format("%,d", getScore()), true);
    if (getGilded() > 0)
        embed.appendField(":star: Gold", "x" + getGilded(), false);
    return embed.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder)

Aggregations

EmbedBuilder (sx.blah.discord.util.EmbedBuilder)103 IOException (java.io.IOException)19 Random (java.util.Random)17 IUser (sx.blah.discord.handle.obj.IUser)14 MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)13 LoadingMessage (me.shadorc.shadbot.utils.object.LoadingMessage)13 EmbedObject (sx.blah.discord.api.internal.json.objects.EmbedObject)12 JSONObject (org.json.JSONObject)11 IMessage (sx.blah.discord.handle.obj.IMessage)10 List (java.util.List)9 AbstractCommand (me.shadorc.shadbot.core.command.AbstractCommand)9 EmbedUtils (me.shadorc.shadbot.utils.embed.EmbedUtils)9 JSONException (org.json.JSONException)9 EventColor (com.cloudcraftgaming.discal.api.enums.event.EventColor)8 Utils (me.shadorc.shadbot.utils.Utils)8 IChannel (sx.blah.discord.handle.obj.IChannel)8 EventData (com.cloudcraftgaming.discal.api.object.event.EventData)7 FormatUtils (me.shadorc.shadbot.utils.FormatUtils)7 File (java.io.File)6 CommandCategory (me.shadorc.shadbot.core.command.CommandCategory)6