Search in sources :

Example 6 with CCommandObject

use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.

the class PurgeBannedData method purgeData.

public void purgeData(long userID, CommandObject command) {
    ListIterator iterator = command.guild.users.profiles.listIterator();
    while (iterator.hasNext()) {
        ProfileObject object = (ProfileObject) iterator.next();
        if (userID == object.getUserID()) {
            iterator.remove();
            purgedProfiles++;
        }
    }
    iterator = command.guild.customCommands.getCommandList().listIterator();
    while (iterator.hasNext()) {
        CCommandObject ccObject = (CCommandObject) iterator.next();
        if (userID == ccObject.getUserID()) {
            iterator.remove();
            purgedCCs++;
        }
    }
    iterator = command.guild.characters.getCharacters(command.guild.get()).listIterator();
    while (iterator.hasNext()) {
        CharacterObject charObject = (CharacterObject) iterator.next();
        if (charObject.getUserID() == userID) {
            iterator.remove();
            purgedCharacters++;
        }
    }
    iterator = command.guild.servers.getServers().listIterator();
    while (iterator.hasNext()) {
        ServerObject serverObject = (ServerObject) iterator.next();
        if (serverObject.getCreatorID() == userID) {
            iterator.remove();
            purgedServers++;
        }
    }
// iterator = Globals.getDailyMessages().getMessages().listIterator();
// while (iterator.hasNext()) {
// DailyMessage dailyObject = (DailyMessage) iterator.next();
// if (dailyObject.getUserID() == userID) {
// iterator.remove();
// purgedDailyMessages++;
// }
// }
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) CharacterObject(com.github.vaerys.objects.CharacterObject) ServerObject(com.github.vaerys.objects.ServerObject) ListIterator(java.util.ListIterator) ProfileObject(com.github.vaerys.objects.ProfileObject)

Example 7 with CCommandObject

use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.

the class CustomCommands method sendCCasJSON.

@Deprecated
public String sendCCasJSON(long channelID, String commandName) {
    IChannel channel = Globals.getClient().getChannelByID(channelID);
    for (CCommandObject c : commands) {
        if (c.getName().equalsIgnoreCase(commandName)) {
            FileHandler.writeToJson(Constants.DIRECTORY_TEMP + c.getName() + ".json", c);
            File file = new File(Constants.DIRECTORY_TEMP + c.getName() + ".json");
            if (RequestHandler.sendFile("> Here is the Raw Data for Custom Command: **" + c.getName() + "**", file, channel).get() == null) {
                RequestHandler.sendMessage("> An error occurred when attempting to getSlashCommands CC data.", channel);
            }
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                Utility.sendStack(e);
            }
            file.delete();
            return null;
        }
    }
    RequestHandler.sendMessage(Constants.ERROR_CC_NOT_FOUND, channel);
    return null;
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) IChannel(sx.blah.discord.handle.obj.IChannel) GuildFile(com.github.vaerys.templates.GuildFile) File(java.io.File)

Example 8 with CCommandObject

use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.

the class CustomCommands method initCustomCommands.

public void initCustomCommands(IGuild guild) {
    // make sure that echo works properly
    boolean echoExists = true;
    CCommandObject echo = getCommand("echo");
    if (echo != null && echo.getContents(false).contains("#")) {
        delCommand("echo", Globals.getClient().getOurUser(), guild);
        echoExists = false;
    } else if (echo == null) {
        echoExists = false;
    }
    if (!echoExists)
        commands.add(new CCommandObject(true, Globals.getClient().getOurUser().getLongID(), "Echo", "<args><dontSanitize>", false));
    // make sure that wiki works properly
    boolean wikiExists = true;
    CCommandObject wiki = getCommand("wiki");
    if (wiki != null && wiki.getContents(false).contains("#")) {
        delCommand("wiki", Globals.getClient().getOurUser(), guild);
        wikiExists = false;
    } else if (wiki == null) {
        wikiExists = false;
    }
    if (!wikiExists)
        commands.add(new CCommandObject(true, Globals.getClient().getOurUser().getLongID(), "Wiki", "http://starbounder.org/Special:Search/<args><replace>{ ;;_}", false));
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject)

Example 9 with CCommandObject

use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.

the class CustomCommands method getUserCommandCount.

public String getUserCommandCount(UserObject user, GuildObject guild) {
    int totalCommands = 0;
    int ccMax = maxCCs(user, guild);
    for (CCommandObject c : commands) {
        if (c.getUserID() == user.longID) {
            totalCommands++;
        }
    }
    return totalCommands + "/" + ccMax;
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject)

Example 10 with CCommandObject

use of com.github.vaerys.objects.CCommandObject in project DiscordSailv2 by Vaerys-Dawn.

the class EditCC method execute.

@Override
public String execute(String args, CommandObject command) {
    ProfileObject object = command.guild.users.getUserByID(command.user.longID);
    if (object != null && object.getSettings().contains(UserSetting.DENY_MAKE_CC)) {
        return "> " + command.user.mention() + ", You have been denied the modification of custom commands.";
    }
    SplitFirstObject getName = new SplitFirstObject(args);
    String rest = getName.getRest();
    if (rest == null) {
        rest = "";
    }
    if (command.message.get().getAttachments().size() != 0) {
        String testLink = command.message.get().getAttachments().get(0).getUrl();
        if (Utility.isImageLink(testLink)) {
            if (rest.length() > 0) {
                rest += " ";
            }
            rest += "<embedImage>{" + testLink + "}";
        } else {
            return "> Custom command attachment must be a valid Image.";
        }
    }
    SplitFirstObject getMode = new SplitFirstObject(rest);
    String mode = getMode.getFirstWord();
    String content = getMode.getRest();
    CCommandObject customCommand = command.guild.customCommands.getCommand(getName.getFirstWord());
    if (customCommand == null) {
        return "> Command Not found.";
    }
    boolean canBypass = GuildHandler.testForPerms(command, Permissions.MANAGE_MESSAGES);
    boolean isAuthor = command.user.longID == customCommand.getUserID();
    // test if can edit
    if ((customCommand.isLocked() && !canBypass) || (!canBypass && !isAuthor)) {
        return "> You do not have permission to edit this command.";
    }
    if (command.guild.customCommands.checkblackList(args) != null) {
        return command.guild.customCommands.checkblackList(args);
    }
    if (customCommand.isLocked() && !canBypass) {
        return "> This command is locked and cannot be edited.";
    }
    switch(mode.toLowerCase()) {
        case "replace":
            return CCEditModes.replace(customCommand, content, command);
        case "toembed":
            return CCEditModes.toEmbed(customCommand);
        case "append":
            return CCEditModes.append(customCommand, content, command);
        case "delet":
        case "delcall":
            return CCEditModes.deleteTag(customCommand);
        case "shitpost":
            return CCEditModes.shitPost(customCommand, command, command.user.get(), command.guild.get());
        case "lock":
            return CCEditModes.lock(customCommand, command, command.user.get(), command.guild.get());
        case "addsearch":
            return CCEditModes.addSearchTag(customCommand, content);
        case "removesearch":
            return CCEditModes.removeSearchTag(customCommand, content);
        default:
            if (content == null || content.isEmpty()) {
                return CCEditModes.replace(customCommand, mode, command);
            } else {
                return CCEditModes.replace(customCommand, mode + " " + content, command);
            }
    }
}
Also used : CCommandObject(com.github.vaerys.objects.CCommandObject) ProfileObject(com.github.vaerys.objects.ProfileObject) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Aggregations

CCommandObject (com.github.vaerys.objects.CCommandObject)14 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)4 File (java.io.File)4 IUser (sx.blah.discord.handle.obj.IUser)4 ProfileObject (com.github.vaerys.objects.ProfileObject)3 ArrayList (java.util.ArrayList)3 IChannel (sx.blah.discord.handle.obj.IChannel)3 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)2 TagObject (com.github.vaerys.templates.TagObject)2 CharacterObject (com.github.vaerys.objects.CharacterObject)1 ServerObject (com.github.vaerys.objects.ServerObject)1 CustomCommands (com.github.vaerys.pogos.CustomCommands)1 TagEmbedImage (com.github.vaerys.tags.cctags.TagEmbedImage)1 GuildFile (com.github.vaerys.templates.GuildFile)1 IOException (java.io.IOException)1 ListIterator (java.util.ListIterator)1 Random (java.util.Random)1 IGuild (sx.blah.discord.handle.obj.IGuild)1