Search in sources :

Example 1 with MessageHandler

use of com.github.vaerys.handlers.MessageHandler in project DiscordSailv2 by Vaerys-Dawn.

the class Sudo method execute.

@Override
public String execute(String args, CommandObject command) {
    if (!command.guild.config.debugMode)
        return "> Debug mode is disabled. No Sudo for you missy.";
    SplitFirstObject sudo = new SplitFirstObject(args);
    UserObject user = Utility.getUser(command, sudo.getFirstWord(), false, false);
    if (user == null) {
        return "> Could not find user.";
    }
    command.setAuthor(user.get());
    if (sudo.getRest() == null) {
        return "> You need to specify some arguments.";
    }
    try {
        new MessageHandler(sudo.getRest(), command, false);
    } catch (Exception e) {
        String errorPos = "";
        for (StackTraceElement s : e.getStackTrace()) {
            if (s.toString().contains("com.github.vaerys")) {
                errorPos = s.toString();
                break;
            }
        }
        StringBuilder builder = new StringBuilder();
        builder.append("> I caught an Error, Please send this Error message and the message that caused this error " + "to my **Direct Messages** so my developer can look at it and try to solve the issue.\n```\n");
        builder.append(e.getClass().getName());
        builder.append(": " + e.getMessage());
        if (!errorPos.isEmpty()) {
            builder.append("\n" + Constants.PREFIX_INDENT + "at " + errorPos);
        }
        builder.append("```");
        RequestHandler.sendMessage(builder.toString(), command.channel.get());
        Utility.sendStack(e);
    }
    return null;
}
Also used : MessageHandler(com.github.vaerys.handlers.MessageHandler) UserObject(com.github.vaerys.masterobjects.UserObject) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Aggregations

MessageHandler (com.github.vaerys.handlers.MessageHandler)1 UserObject (com.github.vaerys.masterobjects.UserObject)1 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1