use of com.github.vaerys.objects.ServerObject in project DiscordSailv2 by Vaerys-Dawn.
the class Servers method editServerDesc.
public String editServerDesc(long userID, String serverName, String desc, IGuild guild) {
for (ServerObject s : servers) {
if (s.getName().equalsIgnoreCase(serverName)) {
boolean bypass = GuildHandler.testForPerms(Globals.getClient().getUserByID(userID), guild, Permissions.MANAGE_MESSAGES);
if (s.getCreatorID() == userID || bypass) {
String check = Utility.checkBlacklist(desc, blackList);
if (check != null) {
return check;
}
if (desc.length() > 1000) {
return "> Could not edit Description, Reason: Too long.";
}
if (StringUtils.countMatches(desc, "\n") > 15) {
return "> Could not edit Description, Reason: Too many lines.";
}
ArrayList<String> newDesc = new ArrayList<>(Arrays.asList(desc.split("\n")));
s.setServerDesc(newDesc);
return "> Server Description Edited.";
} else
return "> You do not have permission to edit this server's Description.";
}
}
return "> Server with that name not found.";
}
use of com.github.vaerys.objects.ServerObject 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.ServerObject 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.";
}
use of com.github.vaerys.objects.ServerObject in project DiscordSailv2 by Vaerys-Dawn.
the class Servers method editIP.
public String editIP(long userID, String serverName, String IP, String port, IGuild guild) {
for (ServerObject s : servers) {
if (s.getName().equalsIgnoreCase(serverName)) {
boolean bypass = GuildHandler.testForPerms(Globals.getClient().getUserByID(userID), guild, Permissions.MANAGE_MESSAGES);
if (s.getCreatorID() == userID || bypass) {
String check = Utility.checkBlacklist(IP + port, blackList);
if (check != null) {
return check;
}
s.setServerIP(IP);
s.setServerPort(port);
return "> Server IP edited.";
} else
return "> You do not have permission to edit this server's IP.";
}
}
return "> Server with that name not found.";
}
use of com.github.vaerys.objects.ServerObject in project DiscordSailv2 by Vaerys-Dawn.
the class Servers method editServerName.
public String editServerName(long userID, String oldServerName, String newServerName, IGuild guild) {
for (ServerObject s : servers) {
if (s.getName().equalsIgnoreCase(oldServerName)) {
boolean bypass = GuildHandler.testForPerms(Globals.getClient().getUserByID(userID), guild, Permissions.MANAGE_MESSAGES);
if (s.getCreatorID() == userID || bypass) {
for (ServerObject so : servers) {
if (so.getName().equalsIgnoreCase(newServerName)) {
return "> Cannot change Server name. That server name is already in use.";
}
}
String check = Utility.checkBlacklist(newServerName, blackList);
if (check != null) {
return check;
}
s.setName(newServerName);
return "> Server Name Edited.";
} else
return "> You do not have permission to edit this server's name.";
}
}
return "> Server with that name not found.";
}
Aggregations