use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class Utility method prepArgs.
public static String prepArgs(String args) {
StringHandler replace = new StringHandler(args);
replace.replace("{", "<u007B>");
replace.replace("}", "<u007D>");
replace.replace("(", "<u0028>");
replace.replace(")", "<u0029>");
replace.replace(":", "<u003A>");
replace.replace(";", "<u003B>");
return replace.toString();
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class ModuleJoinMessages method stats.
@Override
public String stats(CommandObject command) {
IChannel channel = command.guild.getChannelByType(ChannelSetting.JOIN_CHANNEL);
StringHandler builder = new StringHandler();
if (channel != null) {
builder.append("Join Channel: " + channel.mention());
}
if (!builder.isEmpty())
builder.append("\n");
builder.append("Message count: " + command.guild.channelData.getJoinMessages().size());
return builder.toString();
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class SubCommandObject method getCommandUsage.
public String getCommandUsage(CommandObject command) {
StringHandler usage = new StringHandler();
StringHandler regexHandler = new StringHandler(regex);
usage.append(command.guild.config.getPrefixCommand());
usage.append(names[0]);
regexHandler.replace("(", "[");
regexHandler.replace(")", "]");
regexHandler.replace("|", "/");
usage.append(regexHandler);
usage.append(" ");
if (this.usage != null && !this.usage.isEmpty()) {
usage.append(this.usage);
}
return usage.toString();
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class Mute method execute.
@Override
public String execute(String args, CommandObject command) {
SplitFirstObject userCall = new SplitFirstObject(args);
IRole mutedRole = command.guild.getMutedRole();
UserObject muted = Utility.getUser(command, userCall.getFirstWord(), false, false);
if (muted == null)
return "> Could not find user";
if (muted.getProfile(command.guild) == null)
muted.addProfile(command.guild);
if (mutedRole == null)
return "> Muted role is not configured.";
// Un mute subtype
if (UN_MUTE.isSubCommand(command)) {
if (!muted.roles.contains(mutedRole))
return "> " + muted.displayName + " is not muted.";
command.guild.users.unMuteUser(muted.longID, command.guild.longID);
return "> " + muted.displayName + " was UnMuted.";
}
if (muted.longID == command.user.longID)
return "> Don't try to mute yourself you numpty.";
if (!Utility.testUserHierarchy(command.client.bot.get(), mutedRole, command.guild.get()))
return "> Cannot Mute " + muted.displayName + ". **" + mutedRole.getName() + "** role has a higher hierarchy than me.";
if (!Utility.testUserHierarchy(command.user.get(), muted.get(), command.guild.get()))
return "> Cannot Mute/UnMute " + muted.displayName + ". User hierarchy higher than yours.";
StringHandler reason = new StringHandler(userCall.getRest());
long timeSecs = Utility.getRepeatTimeValue(reason);
boolean isStrike = false;
// if (reason.toString().isEmpty()) return "> Reason Cannot be empty";
// mute the offender
command.guild.users.muteUser(muted.longID, timeSecs, command.guild.longID);
// build the response
// time value
String timeValue = "";
if (timeSecs > 0) {
timeValue = Utility.formatTime(timeSecs, true);
}
if (Pattern.compile("(^⚠ | ⚠|⚠)").matcher(reason.toString()).find()) {
reason.replaceRegex("(^⚠ | ⚠|⚠)", "");
isStrike = true;
}
// setup muted messages
// name was muted for timevalue;
String msgFormat = "> **%s** was muted%s";
// > name was muted for timevalue by mod in channel with `reason`;
String adminMsg = " by %s in %s with reason `%s`.";
// name muted with reason `reason` for timevalue in channel;
String modnote = "Muted by %s. Reason: `%s`. Time: %s. Channel: %s.";
IChannel adminChannel = command.guild.getChannelByType(ChannelSetting.ADMIN);
if (reason.toString().isEmpty())
reason.setContent("No reason given");
// final responses:
String responseTime = !timeValue.isEmpty() ? " for " + timeValue : "";
String response = String.format(msgFormat, muted.mention(), responseTime);
if (adminChannel != null) {
RequestHandler.sendMessage(response + String.format(adminMsg, command.user.displayName, command.channel.mention, reason), adminChannel);
}
muted.getProfile(command.guild).addSailModNote(String.format(modnote, command.user.displayName, reason, timeValue, command.channel.mention), command, isStrike);
return response + ".";
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class ListJoinMessages method execute.
@Override
public String execute(String args, CommandObject command) {
XEmbedBuilder builder = new XEmbedBuilder(command);
StringHandler handler = new StringHandler();
List<JoinMessage> messages = command.guild.channelData.getJoinMessages();
if (messages.size() == 0) {
return "> No Messages exist right now, you can create some with **" + new NewJoinMessage().getUsage(command) + "**";
}
int page = 1;
try {
page = Integer.parseInt(args);
if (page <= 0)
return "> Invalid Page.";
} catch (NumberFormatException e) {
if (args != null && !args.isEmpty()) {
return "> Not a valid number";
}
}
page--;
List<String> pages = new LinkedList<>();
int index = 1;
int i = 0;
for (JoinMessage m : messages) {
if (i == 10) {
i = 0;
pages.add(handler.toString());
handler.emptyContent();
}
String shortNote = Utility.truncateString(Utility.removeFun(m.getContent()), 65);
handler.append("**> Message #" + index + "**");
handler.append("\n" + shortNote);
handler.append("\n");
i++;
index++;
}
pages.add(handler.toString());
if (page >= pages.size()) {
return "> Invalid Page.";
}
builder.withTitle("> Join Message list");
builder.withDesc(pages.get(page) + "\n\n" + missingArgs(command));
builder.withFooterText("Page " + (page + 1) + "/" + pages.size() + " | Total Join Messages: " + messages.size());
builder.send(command.channel);
return null;
}
Aggregations