Search in sources :

Example 21 with IUser

use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.

the class BotInfo method execute.

@Override
public String execute(String args, CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    StringBuilder response = new StringBuilder();
    IUser creator = command.client.fetchUser(153159020528533505L);
    IUser andriel = command.client.fetchUser(175442602508812288L);
    IUser c0bra = command.client.fetchUser(222041304761237505L);
    builder.withTitle("Information about " + Globals.botName);
    response.append("Created by: **@" + creator.getName() + "#" + creator.getDiscriminator() + "**.");
    response.append("\nCreated entirely using Java 8 and the **[Discord4J Libraries](https://discord4j.com/)**.");
    response.append("\nSupport " + Globals.botName + " on **[Patreon](https://www.patreon.com/DawnFelstar)**.");
    response.append("\nFind " + Globals.botName + " on **[GitHub](https://github.com/Vaerys-Dawn/DiscordSailv2)**.");
    response.append("\nBot's Support Discord: **https://discord.gg/XSyQQrR**.");
    response.append("\n\nContributors: **@" + andriel.getName() + "#" + andriel.getDiscriminator() + "**, ");
    response.append("**@").append(c0bra.getName()).append("#").append(c0bra.getDiscriminator()).append("**.");
    builder.withDesc(response.toString());
    builder.withThumbnail(command.client.bot.getAvatarURL());
    builder.withFooterText("Bot Version: " + Globals.version + " | D4J Version: " + Globals.d4jVersion);
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) IUser(sx.blah.discord.handle.obj.IUser)

Example 22 with IUser

use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.

the class GroupUp method execute.

@Override
public String execute(String args, CommandObject command) {
    String presence = null;
    if (!args.isEmpty()) {
        presence = args;
    }
    ArrayList<GroupUpObject> list = command.guild.channelData.getGroupUpObjects();
    for (GroupUpObject g : list) {
        if (command.user.longID == g.getUserID()) {
            list.remove(g);
            return "> You have been removed from the list.";
        }
    }
    list.add(new GroupUpObject(presence, command.user.longID));
    // person added to list :D
    ArrayList<String> completeList = new ArrayList<>();
    for (GroupUpObject g : list) {
        IUser user = command.client.get().getUserByID(g.getUserID());
        if (user != null) {
            IPresence userPres = user.getPresence();
            if (!userPres.getStatus().equals(StatusType.DND) && !userPres.getStatus().equals(StatusType.OFFLINE) && !userPres.getStatus().equals(StatusType.UNKNOWN)) {
                if (g.getPresence() != null || userPres.getText().isPresent()) {
                    String newPres;
                    if (g.getPresence() == null) {
                        newPres = userPres.getText().get();
                    } else {
                        newPres = g.getPresence();
                    }
                    StringBuilder builder = new StringBuilder(newPres);
                    if (builder.length() > 40) {
                        builder.delete(0, 40);
                        builder.append("...");
                    }
                    completeList.add(indent + user.mention() + " Playing: " + builder.toString());
                } else {
                    completeList.add(indent + user.mention());
                }
            }
        }
    }
    return "**> You have been added to the GroupUp list.**\n\n" + "Here are the others currently waiting:\n" + Utility.listFormatter(completeList, false) + "\n*To opt out simply run this command again*\n" + Utility.getCommandInfo(this, command);
}
Also used : IPresence(sx.blah.discord.handle.obj.IPresence) ArrayList(java.util.ArrayList) GroupUpObject(com.github.vaerys.objects.GroupUpObject) IUser(sx.blah.discord.handle.obj.IUser)

Example 23 with IUser

use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.

the class CheckPixelRoles method execute.

@Override
public String execute(String args, CommandObject command) {
    IMessage working = RequestHandler.sendMessage("`Working...`", command.channel.get()).get();
    for (IUser user : command.guild.getUsers()) {
        GuildHandler.checkUsersRoles(user.getLongID(), command.guild);
    }
    RequestHandler.deleteMessage(working);
    return "> Done.";
}
Also used : IMessage(sx.blah.discord.handle.obj.IMessage) IUser(sx.blah.discord.handle.obj.IUser)

Example 24 with IUser

use of sx.blah.discord.handle.obj.IUser in project Shadbot by Shadorc.

the class UserInfoCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException {
    List<IUser> mentions = context.getMessage().getMentions();
    IUser user = mentions.isEmpty() ? context.getAuthor() : mentions.get(0);
    String creationDate = String.format("%s%n(%s)", TimeUtils.toLocalDate(user.getCreationDate()).format(dateFormatter), FormatUtils.formatLongDuration(user.getCreationDate()));
    String joinDate = String.format("%s%n(%s)", TimeUtils.toLocalDate(context.getGuild().getJoinTimeForUser(user)).format(dateFormatter), FormatUtils.formatLongDuration(context.getGuild().getJoinTimeForUser(user)));
    EmbedBuilder embed = EmbedUtils.getDefaultEmbed().setLenient(true).withAuthorName(String.format("Info about user \"%s\"%s", user.getName(), user.isBot() ? " (Bot)" : "")).withThumbnail(user.getAvatarURL()).appendField("Display name", user.getDisplayName(context.getGuild()), true).appendField("User ID", Long.toString(user.getLongID()), true).appendField("Creation date", creationDate, true).appendField("Join date", joinDate, true).appendField("Roles", FormatUtils.format(user.getRolesForGuild(context.getGuild()), IRole::getName, "\n"), true).appendField("Status", StringUtils.capitalize(user.getPresence().getStatus().toString()), true).appendField("Playing text", user.getPresence().getText().orElse(null), true);
    BotUtils.sendMessage(embed.build(), context.getChannel());
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) IUser(sx.blah.discord.handle.obj.IUser)

Example 25 with IUser

use of sx.blah.discord.handle.obj.IUser in project Shadbot by Shadorc.

the class PollManager method show.

protected void show() {
    int count = 1;
    StringBuilder choicesStr = new StringBuilder();
    for (String choice : choicesMap.keySet()) {
        List<IUser> votersList = choicesMap.get(choice);
        choicesStr.append(String.format("%n\t**%d.** %s", count, choice));
        if (!votersList.isEmpty()) {
            choicesStr.append(String.format(" *(Vote: %d)*", votersList.size()));
            choicesStr.append(String.format("%n\t\t%s", StringUtils.truncate(FormatUtils.format(votersList, IUser::getName, ", "), 30)));
        }
        count++;
    }
    EmbedBuilder embed = EmbedUtils.getDefaultEmbed().withAuthorName(String.format("Poll (Created by: %s)", this.getAuthor().getName())).withThumbnail(this.getAuthor().getAvatarURL()).appendDescription(String.format("Vote using: `%s%s <choice>`%n%n__**%s**__%s", this.getPrefix(), this.getCmdName(), question, choicesStr.toString())).withFooterIcon("https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/Clock_simple_white.svg/2000px-Clock_simple_white.svg.png");
    if (this.isTaskDone()) {
        embed.withFooterText("Finished");
    } else {
        embed.withFooterText(String.format("Time left: %s", FormatUtils.formatShortDuration(TimeUnit.SECONDS.toMillis(duration) - TimeUtils.getMillisUntil(startTime))));
    }
    RequestFuture<IMessage> messageRequest = message.send(embed.build());
    if (messageRequest != null) {
        messageRequest.get();
    }
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) IMessage(sx.blah.discord.handle.obj.IMessage) IUser(sx.blah.discord.handle.obj.IUser)

Aggregations

IUser (sx.blah.discord.handle.obj.IUser)67 ArrayList (java.util.ArrayList)15 IGuild (sx.blah.discord.handle.obj.IGuild)13 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)13 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)9 IMessage (sx.blah.discord.handle.obj.IMessage)9 IRole (sx.blah.discord.handle.obj.IRole)8 List (java.util.List)7 MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)7 IllegalCmdArgumentException (me.shadorc.shadbot.exception.IllegalCmdArgumentException)6 IChannel (sx.blah.discord.handle.obj.IChannel)6 HashMap (java.util.HashMap)5 CCommandObject (com.github.vaerys.objects.CCommandObject)4 AbstractCommand (me.shadorc.shadbot.core.command.AbstractCommand)4 CommandCategory (me.shadorc.shadbot.core.command.CommandCategory)4 Context (me.shadorc.shadbot.core.command.Context)4 Command (me.shadorc.shadbot.core.command.annotation.Command)4 BotUtils (me.shadorc.shadbot.utils.BotUtils)4 FormatUtils (me.shadorc.shadbot.utils.FormatUtils)4 TextUtils (me.shadorc.shadbot.utils.TextUtils)4