use of com.github.vaerys.objects.ProfileObject in project DiscordSailv2 by Vaerys-Dawn.
the class PixelHandler method rank.
public static long rank(GuildUsers guildUsers, IGuild guild, long userID) {
if (isUnRanked(userID, guildUsers, guild)) {
return -1;
}
ProfileObject user = guildUsers.getUserByID(userID);
// rank calc
long rank = 0;
ArrayList<ProfileObject> users = (ArrayList<ProfileObject>) guildUsers.getProfiles().clone();
// sort so that can accurately check rank
Utility.sortUserObjects(users, false);
// for all the users
for (int i = 0; i < users.size(); i++) {
if (users.get(i).getUserID() == userID) {
return rank + 1;
} else {
boolean hideRank = isUnRanked(users.get(i).getUserID(), guildUsers, guild);
if (!hideRank && user.getXP() != users.get(i).getXP()) {
rank++;
}
}
}
// this should never occur
return rank;
}
use of com.github.vaerys.objects.ProfileObject in project DiscordSailv2 by Vaerys-Dawn.
the class SpamHandler method checkForInvites.
public static boolean checkForInvites(CommandObject command) {
GuildConfig guildconfig = command.guild.config;
if (!guildconfig.denyInvites) {
return false;
}
IMessage message = command.message.get();
IGuild guild = command.guild.get();
IUser author = command.user.get();
List<String> inviteformats = new ArrayList<String>() {
{
add("discord.gg");
add("discordapp.com/Invite/");
}
};
if (GuildHandler.testForPerms(command, Permissions.MANAGE_MESSAGES))
return false;
boolean inviteFound = false;
boolean shouldDelete = false;
ProfileObject object = command.user.getProfile(command.guild);
boolean userSettingDenied = false;
if (object != null) {
userSettingDenied = object.getSettings().contains(UserSetting.DENY_INVITES);
}
for (String s : inviteformats) {
if (message.toString().toLowerCase().contains(s.toLowerCase())) {
inviteFound = true;
}
}
boolean isTrusted = guildconfig.testIsTrusted(author, guild);
if (userSettingDenied || !isTrusted) {
shouldDelete = true;
}
if (inviteFound && shouldDelete) {
String response;
if (userSettingDenied) {
response = "> " + command.user.mention() + ", you do not have permission to post Instant Invites.";
} else {
response = "> " + command.user.mention() + ", please do not post Instant Invites.";
}
RequestHandler.deleteMessage(message);
command.guild.sendDebugLog(command, "INVITE_REMOVAL", "REMOVED", message.getContent());
RequestHandler.sendMessage(response, command.channel.get());
return true;
}
return false;
}
use of com.github.vaerys.objects.ProfileObject 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);
}
}
}
use of com.github.vaerys.objects.ProfileObject in project DiscordSailv2 by Vaerys-Dawn.
the class NewCC 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 creation of custom commands.";
}
if (command.guild.getChannelsByType(ChannelSetting.CC_DENIED).contains(command.channel.get()))
return "> This Channel has CCs Denied, You cannot create ccs here.";
boolean isShitpost = false;
boolean isLocked = false;
SplitFirstObject splitFirst = new SplitFirstObject(args);
List<IChannel> shitpostChannels = command.guild.getChannelsByType(ChannelSetting.SHITPOST);
if (shitpostChannels != null) {
for (IChannel channel : shitpostChannels) {
if (command.channel.longID == channel.getLongID()) {
isShitpost = true;
}
}
}
if (object.getSettings().contains(UserSetting.AUTO_SHITPOST)) {
isShitpost = true;
}
String nameCC = splitFirst.getFirstWord();
String argsCC = splitFirst.getRest();
if (handleNameFilter(command, nameCC)) {
return "> Custom Commands cannot have the same name as built-in commands.";
}
if ((argsCC == null || argsCC.isEmpty()) && command.message.get().getAttachments().size() == 0) {
return "> Custom command contents cannot be blank.";
}
if (command.message.get().getAttachments().size() != 0) {
String testLink = command.message.get().getAttachments().get(0).getUrl();
if (Utility.isImageLink(testLink)) {
if (argsCC == null || argsCC.isEmpty()) {
argsCC = "<embedImage>{" + testLink + "}";
} else {
argsCC += "<embedImage>{" + testLink + "}";
}
} else {
return "> Custom command attachment must be a valid Image.";
}
}
if (nameCC.contains("\n")) {
return "> Command name cannot contain Newlines.";
}
if (argsCC.contains("<shitpost>")) {
argsCC.replace("<shitpost>", "");
isShitpost = true;
}
if (argsCC.contains("<lock>") && GuildHandler.testForPerms(command, Permissions.MANAGE_MESSAGES)) {
argsCC.replace("<lock>", "");
isLocked = true;
}
return command.guild.customCommands.addCommand(isLocked, nameCC, argsCC, isShitpost, command);
}
Aggregations