Search in sources :

Example 51 with IUser

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

the class Respond method execute.

@Override
public String execute(String args, CommandObject command) {
    SplitFirstObject response = new SplitFirstObject(args);
    IUser recipient = command.client.get().getUserByID(Utility.stringLong(response.getFirstWord()));
    return sendDM(response.getRest(), command, recipient, command.user.username + ": ");
}
Also used : IUser(sx.blah.discord.handle.obj.IUser) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Example 52 with IUser

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

the class Server method execute.

@Override
public String execute(String args, CommandObject command) {
    for (ServerObject s : command.guild.servers.getServers()) {
        if (s.getName().equalsIgnoreCase(args)) {
            IUser user = command.guild.getUserByID(s.getCreatorID());
            boolean isGuildUser = true;
            if (user == null) {
                user = command.client.get().fetchUser(s.getCreatorID());
                isGuildUser = false;
            }
            StringBuilder builder = new StringBuilder();
            builder.append("**" + s.getName() + "**\n");
            builder.append("**IP:** " + s.getServerIP() + " **Port:** " + s.getServerPort() + "\n");
            if (isGuildUser) {
                builder.append("**Listing Creator:** " + user.getDisplayName(command.guild.get()) + "\n");
            } else {
                builder.append("**Listing Creator:** " + user.getName() + "#" + user.getDiscriminator() + "\n");
            }
            builder.append(s.getServerDesc());
            command.user.sendDm(builder.toString());
            return "> Server info has been sent to your DMs";
        }
    }
    return "> Server with that name not found.";
}
Also used : ServerObject(com.github.vaerys.objects.ServerObject) IUser(sx.blah.discord.handle.obj.IUser)

Example 53 with IUser

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

the class MentionCommand method isCall.

@Override
public boolean isCall(String args, CommandObject command) {
    if (command.guild.client.bot == null) {
        command.guild.sendDebugLog(command, "MENTION_COMMAND", "BOT_NULL", command.message.getContent());
        return false;
    }
    SplitFirstObject mention = new SplitFirstObject(args);
    if (mention.getRest() == null) {
        return false;
    }
    List<IUser> users = command.message.getMentions();
    IUser bot = command.client.bot.get();
    if (bot == null || !users.contains(bot)) {
        return false;
    }
    SplitFirstObject call = new SplitFirstObject(mention.getRest());
    for (String s : names) {
        String regex = "^(<@|<@!)" + command.client.bot.longID + "> " + s.toLowerCase();
        String toMatch = mention.getFirstWord() + " " + call.getFirstWord().toLowerCase();
        Matcher matcher = Pattern.compile(regex).matcher(toMatch);
        if (matcher.matches()) {
            return true;
        }
    }
    return false;
}
Also used : Matcher(java.util.regex.Matcher) IUser(sx.blah.discord.handle.obj.IUser) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Example 54 with IUser

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

the class GetCCData method execute.

@Override
public String execute(String args, CommandObject command) {
    for (CCommandObject c : command.guild.customCommands.getCommandList()) {
        if (c.getName().equalsIgnoreCase(args)) {
            StringBuilder content = new StringBuilder("Command Name: \"" + c.getName() + "\"");
            IUser createdBy = command.guild.getUserByID(c.getUserID());
            if (createdBy == null)
                createdBy = command.client.get().fetchUser(c.getUserID());
            if (createdBy == null)
                content.append("\nCreated by: \"null\"");
            else
                content.append("\nCreated by: \"" + createdBy.getName() + "#" + createdBy.getDiscriminator() + "\"");
            content.append("\nTimes run: \"" + c.getTimesRun() + "\"");
            content.append("\nContents: \"" + c.getContents(false) + "\"");
            String filePath = Constants.DIRECTORY_TEMP + command.message.longID + ".txt";
            FileHandler.writeToFile(filePath, content.toString(), false);
            RequestHandler.sendFile("> Here is the raw data for Custom Command: **" + c.getName() + "**", new File(filePath), command.channel.get());
            try {
                Thread.sleep(4000);
                new File(filePath).delete();
            } catch (InterruptedException e) {
                Utility.sendStack(e);
            }
            return "";
        }
    }
    return "> Custom command " + args + " could not be found.";
// return command.customCommands.sendCCasJSON(command.channelSID, args);
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) IUser(sx.blah.discord.handle.obj.IUser) File(java.io.File)

Example 55 with IUser

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

the class InfoCC method execute.

@Override
public String execute(String args, CommandObject command) {
    CCommandObject customCommand = command.guild.customCommands.getCommand(args);
    if (customCommand == null) {
        return Constants.ERROR_CC_NOT_FOUND;
    }
    StringBuilder builder = new StringBuilder();
    XEmbedBuilder embedBuilder = new XEmbedBuilder(command);
    String title = "> Here is the information for command: **" + customCommand.getName() + "**\n";
    IUser createdBy = command.guild.getUserByID(customCommand.getUserID());
    if (createdBy == null)
        createdBy = command.client.get().fetchUser(customCommand.getUserID());
    if (createdBy == null)
        builder.append("Creator: **Null**\n");
    else
        builder.append("Creator: **@" + createdBy.getName() + "#" + createdBy.getDiscriminator() + "**\n");
    builder.append("Time Run: **" + customCommand.getTimesRun() + "**\n");
    builder.append("Is Locked: **" + customCommand.isLocked() + "**\n");
    builder.append("Is ShitPost: **" + customCommand.isShitPost() + "**");
    embedBuilder.appendField(title, builder.toString(), false);
    RequestHandler.sendEmbedMessage("", embedBuilder, command.channel.get());
    return null;
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) 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