Search in sources :

Example 1 with LogObject

use of com.github.vaerys.objects.LogObject in project DiscordSailv2 by Vaerys-Dawn.

the class AnnotationListener method onMessageReceivedEvent.

@EventSubscriber
public void onMessageReceivedEvent(MessageReceivedEvent event) {
    if (!Globals.isReady)
        return;
    try {
        if (event.getAuthor().isBot())
            return;
        CommandObject command = new CommandObject(event.getMessage());
        // Set Console Response Channel.
        if (command.user.get().equals(command.client.creator)) {
            Globals.consoleMessageCID = command.channel.longID;
        }
        command.guild.handleWelcome(command);
        // message and command handling
        new MessageHandler(command.message.get().getContent(), command, event.getChannel().isPrivate());
    } 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(), event.getChannel());
        Globals.addToLog(new LogObject("ERROR", "MESSAGE_HANDLER", event.getMessage().getContent(), event.getChannel().getLongID(), event.getAuthor().getLongID(), event.getMessageID(), event.getGuild().getLongID()));
        Utility.sendStack(e);
    }
}
Also used : CommandObject(com.github.vaerys.commands.CommandObject) LogObject(com.github.vaerys.objects.LogObject) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Example 2 with LogObject

use of com.github.vaerys.objects.LogObject in project DiscordSailv2 by Vaerys-Dawn.

the class GuildObject method sendDebugLog.

public void sendDebugLog(CommandObject command, String type, String name, String contents) {
    GuildLogObject object = new GuildLogObject(command, type, name, contents);
    String output = object.getOutput(command);
    if (command.guild.get() != null) {
        guildLog.addLog(object, command.guild.longID);
    } else {
        Globals.addToLog(new LogObject(object, -1));
    }
    logger.trace(output);
}
Also used : GuildLogObject(com.github.vaerys.objects.GuildLogObject) GuildLogObject(com.github.vaerys.objects.GuildLogObject) LogObject(com.github.vaerys.objects.LogObject)

Example 3 with LogObject

use of com.github.vaerys.objects.LogObject in project DiscordSailv2 by Vaerys-Dawn.

the class GuildLog method addLog.

public void addLog(GuildLogObject logObject, long guildID) {
    logs.add(logObject);
    Globals.addToLog(new LogObject(logObject, guildID));
    if (logs.size() > 1000) {
        logs.remove(0);
    }
}
Also used : LogObject(com.github.vaerys.objects.LogObject) GuildLogObject(com.github.vaerys.objects.GuildLogObject)

Aggregations

LogObject (com.github.vaerys.objects.LogObject)3 GuildLogObject (com.github.vaerys.objects.GuildLogObject)2 CommandObject (com.github.vaerys.commands.CommandObject)1 EventSubscriber (sx.blah.discord.api.events.EventSubscriber)1