use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class SubCommandObject method getHelpDesc.
public String getHelpDesc(CommandObject command) {
StringHandler builder = new StringHandler();
builder.append(description + "\n");
builder.append("**Type: **" + type.toString() + ".");
// display permissions
if (permissions != null && permissions.length != 0) {
builder.append("\n**Perms: **");
ArrayList<String> permList = new ArrayList<>(permissions.length);
for (Permissions p : permissions) {
permList.add(Utility.enumToString(p));
}
builder.append(Utility.listFormatter(permList, true));
}
if (names.length > 1) {
List<String> aliases = Arrays.asList(names).stream().map(s -> command.guild.config.getPrefixCommand() + s).collect(Collectors.toList());
aliases.remove(0);
builder.append("\n**Aliases:** " + Utility.listFormatter(aliases, true));
}
return builder.toString();
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class RemindMe method execute.
@Override
public String execute(String args, CommandObject command) {
StringHandler contents = new StringHandler(args);
long timeSecs = Utility.getRepeatTimeValue(contents);
if (timeSecs == -1) {
return "> Could not find a valid time value.\n" + Utility.getCommandInfo(this, command);
}
if (timeSecs < 30) {
return "> You can't set a reminder for less than 30 seconds.";
}
if (timeSecs > 60 * 24 * 365 * 60) {
return "> What are you doing... that reminder is set for over a year from now... you cant do that.";
}
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
now = now.plusSeconds(timeSecs);
String response = TimerHandler.addReminder(command.user.longID, command.channel.longID, now.toEpochSecond(), contents.toString());
int maxSlots = Globals.maxReminderSlots;
if (command.user.isPatron) {
maxSlots += maxSlots;
}
String timeValue = Utility.formatTime(timeSecs, true);
switch(response) {
case "MAX":
return "> You can only have " + maxSlots + " reminders.";
case "INTERRUPTS":
return "> Reminders cannot be within 5 minutes of each other.";
default:
return "> Reminder set for " + timeValue + " from now.";
}
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class ModNote method createListEmbed.
private String createListEmbed(ProfileObject user, CommandObject command) {
if (user.modNotes == null || user.modNotes.size() == 0) {
return "> " + user.getUser(command.guild).displayName + " doesn't have any notes yet.";
}
UserObject userObject = user.getUser(command.guild);
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withColor(userObject.color);
builder.withTitle("Notes for " + userObject.displayName);
// avatar
if (userObject.get() != null)
builder.withThumbnail(userObject.get().getAvatarURL());
else
builder.withThumbnail(user.getDefaultAvatarURL());
// get all notes and put together the bits and bobs
int counter = 0;
String noteLine = "**Note #%d:**\n%s\n";
StringHandler content = new StringHandler();
for (ModNoteObject noteObject : user.modNotes) {
String shortNote = Utility.truncateString(Utility.removeFun(noteObject.getNote()), 65);
if (noteObject.getStrike()) {
content.append("⚠ ");
}
content.append(String.format(noteLine, ++counter, shortNote));
}
builder.withDesc(content.toString());
// finalize and send message:
builder.withFooterText("Total Notes: " + user.modNotes.size());
builder.send(command.channel);
return null;
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class Client method refreshPatreonToken.
public static void refreshPatreonToken(String clientID, String clientSecret, String refreshToken) {
try {
patreonOAuth = new PatreonOAuth(clientID, clientSecret, "");
PatreonOAuth.TokensResponse refresh = patreonOAuth.refreshTokens(refreshToken);
StringHandler tokenData = new StringHandler();
tokenData.append(refresh.getAccessToken() + "\n");
tokenData.append(clientID + "\n");
tokenData.append(clientSecret + "\n");
tokenData.append(refresh.getRefreshToken());
FileHandler.writeToFile(Constants.FILE_PATREON_TOKEN, tokenData.toString(), true);
patreonApi = new PatreonAPI(refresh.getAccessToken());
} catch (HttpStatusException e) {
if (e.getStatusCode() == 401) {
logger.error("Refresh Token is invalid.");
return;
}
Utility.sendStack(e);
} catch (IOException e) {
Utility.sendStack(e);
}
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class Utility method removePrep.
public static String removePrep(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();
}
Aggregations