use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.
the class TagList method validate.
private static void validate(List<TagObject> tags) {
for (TagObject c : tags) {
logger.trace("Validating Tag: " + c.getClass().getName());
String errorReport = c.validate();
Globals.addToErrorStack(errorReport);
}
sort(tags);
}
use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.
the class RandomCC method execute.
@Override
public String execute(String args, CommandObject command) {
Random random = new Random();
int counter = 0;
List<CCommandObject> commands = command.guild.customCommands.getCommandList();
CCommandObject randCC = commands.get(random.nextInt(commands.size()));
while (!command.channel.settings.contains(ChannelSetting.SHITPOST) && randCC.isShitPost() && command.guild.config.shitPostFiltering) {
if (counter > 25) {
return "> Your server has way to many shitpost commands, I couldn't find you a normal one.";
}
randCC = commands.get(random.nextInt(commands.size()));
try {
Thread.sleep(50);
} catch (InterruptedException e) {
Utility.sendStack(e);
}
counter++;
}
String response = randCC.getContents(true);
for (TagObject t : TagList.getType(TagType.CC)) {
if (t.name.equals(new TagEmbedImage(0).name)) {
response = t.handleTag(response + "\n`" + command.guild.config.getPrefixCC() + randCC.getName() + "`", command, args);
} else {
response = t.handleTag(response, command, args);
}
}
return response;
}
use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.
the class CCHandler method handleCommand.
public static void handleCommand(String args, CommandObject command) {
// cc lockout handling
SplitFirstObject commandName = new SplitFirstObject(args);
CCommandObject commandObject = command.guild.customCommands.getCommand(commandName.getFirstWord(), command);
String ccArgs = commandName.getRest();
if (ccArgs == null) {
ccArgs = "";
}
if (commandObject == null)
return;
List<IChannel> ccDenied = command.guild.getChannelsByType(ChannelSetting.CC_DENIED);
if (ccDenied.contains(command.channel.get())) {
RequestHandler.sendMessage("> Custom Command usage has been disabled for this channel.", command.channel);
return;
}
ProfileObject object = command.guild.users.getUserByID(command.user.longID);
if (object != null && object.getSettings().contains(UserSetting.DENY_USE_CCS)) {
RequestHandler.sendMessage("> Nothing interesting happens. `(ERROR: 403)`", command.channel.get());
return;
}
command.guild.sendDebugLog(command, "CUSTOM_COMMAND", commandObject.getName(command), ccArgs);
String contents = commandObject.getContents(true);
// shitpost handling
if (commandObject.isShitPost() && command.guild.config.shitPostFiltering && !GuildHandler.testForPerms(command, Permissions.MANAGE_CHANNELS)) {
List<IChannel> channels = command.guild.getChannelsByType(ChannelSetting.SHITPOST);
if (channels.size() != 0 && !channels.contains(command.channel.get())) {
channels = command.user.getVisibleChannels(channels);
List<String> channelMentions = Utility.getChannelMentions(channels);
RequestHandler.sendMessage(Utility.getChannelMessage(channelMentions), command.channel.get());
return;
}
}
// tag handling
for (TagObject t : TagList.getType(TagType.CC)) {
contents = t.handleTag(contents, command, ccArgs);
if (contents == null)
return;
}
RequestHandler.sendMessage(contents, command.channel.get());
}
use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.
the class JoinMessage method getContent.
public String getContent(CommandObject command) {
List<TagObject> tags = TagList.getType(TagType.JOIN_MESSAGES);
String message = content;
for (TagObject t : tags) {
message = t.handleTag(message, command, "");
}
return message;
}
use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.
the class DailyMessage method getContents.
public String getContents(CommandObject command) {
String newContent = content;
for (TagObject t : TagList.getType(TagType.DAILY)) {
newContent = t.handleTag(newContent, command, "");
}
char[] prefixCheck = new char[4];
newContent.getChars(0, 4, prefixCheck, 0);
boolean found = false;
for (char c : prefixCheck) {
if (c == '>') {
found = true;
}
}
if (!found)
newContent = "> " + newContent;
return newContent;
}
Aggregations