Search in sources :

Example 1 with Restart

use of com.github.vaerys.commands.creator.Restart in project DiscordSailv2 by Vaerys-Dawn.

the class CreatorHandler method restart.

@EventSubscriber
public void restart(MessageReceivedEvent event) {
    CommandObject command = new CommandObject(event.getMessage());
    Restart restart = new Restart();
    if (restart.isCall(event.getMessage().getContent(), command)) {
        List<Long> auth = new LinkedList<>();
        try {
            List<String> toParse = FileHandler.readFromFile(Constants.FILE_AUTH_TO_RESTART);
            auth.addAll(toParse.stream().map(Long::parseUnsignedLong).collect(Collectors.toList()));
        } catch (NumberFormatException e) {
        // do nothing
        }
        auth.add(Globals.creatorID);
        if (auth.contains(event.getAuthor().getLongID())) {
            restart.execute("", command);
            return;
        }
    }
}
Also used : CommandObject(com.github.vaerys.commands.CommandObject) Restart(com.github.vaerys.commands.creator.Restart) LinkedList(java.util.LinkedList) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Aggregations

CommandObject (com.github.vaerys.commands.CommandObject)1 Restart (com.github.vaerys.commands.creator.Restart)1 LinkedList (java.util.LinkedList)1 EventSubscriber (sx.blah.discord.api.events.EventSubscriber)1