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++;
// }
// }
}
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;
}
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));
}
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;
}
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);
}
}
}
Aggregations