Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @CommandAnnotation(name = "TagSystem", description = "tests the tag system", usage = "[args]",
- type = Constants.TYPE_ADMIN, channel = Constants.CHANNEL_SHITPOST, requiresArgs = true)
- public String testtags() {
- String response = args;
- String tagRandom;
- String tagRegex;
- String prefixRandom = "#random#{";
- String prefixRegex = "#regex#{";
- String lastAttepmt;
- try {
- if (response.contains(prefixRandom)) {
- do {
- lastAttepmt = response;
- tagRandom = StringUtils.substringBetween(args, prefixRandom, "}");
- if (tagRandom != null) {
- ArrayList<String> splitRandom = new ArrayList<>(Arrays.asList(tagRandom.split(";")));
- Random random = new Random();
- String toRegex = "#random#\\{" + tagRandom + "\\}";
- response = response.replaceFirst(toRegex, splitRandom.get(random.nextInt(splitRandom.size())));
- }
- } while (StringUtils.countMatches(response, prefixRandom) > 0 && (!lastAttepmt.equals(response)));
- }
- if (response.contains(prefixRegex)) {
- do {
- lastAttepmt = response;
- tagRegex = StringUtils.substringBetween(args, prefixRegex, "}");
- if (tagRegex != null) {
- ArrayList<String> splitRegex = new ArrayList<>(Arrays.asList(tagRegex.split(";")));
- String toRegex = "#regex#\\{" + tagRegex + "\\}";
- if (splitRegex.size() == 2) {
- response = response.replaceAll(toRegex, "");
- response = response.replaceAll(splitRegex.get(0), splitRegex.get(1));
- } else {
- response = response.replaceAll(tagRegex, "#ERROR#");
- }
- }
- } while (StringUtils.countMatches(response, prefixRegex) > 0 && (!lastAttepmt.equals(response)));
- }
- } catch (PatternSyntaxException ex) {
- return "> An Error occurred while attempting to run this command.";
- }
- response = response.replaceAll("#author#", author.getDisplayName(guild));
- response = response.replaceAll("#channel#", channel.mention());
- response = response.replaceAll("#guild#", guild.getName());
- response = response.replaceAll("#authorID#", author.getID());
- response = response.replaceAll("#channelID#", channel.getID());
- response = response.replaceAll("#guildID#", guild.getID());
- response = response.replaceAll("@everyone,", "**[REDACTED]**");
- response = response.replaceAll("@here", "**[REDACTED]**");
- return response;
- }
Advertisement
Add Comment
Please, Sign In to add comment