use of com.discordbolt.boltbot.system.mysql.data.persistent.UserData in project BoltBot by DiscordBolt.
the class SeenModule method seenCommand.
@BotCommand(command = "seen", module = "Seen Module", description = "See when the user was last online.", usage = "Seen [User]", minArgs = 2, maxArgs = 100)
public static void seenCommand(CommandContext cc) throws CommandException {
IUser searchUser = UserUtil.findUser(cc.getMessage(), cc.getMessageContent().indexOf(' ') + 1);
String name = cc.getMessageContent().substring(cc.getMessageContent().indexOf(' ') + 1, cc.getMessageContent().length());
if (searchUser == null)
throw new CommandArgumentException("Sorry, I could not find '" + name + "'.");
Optional<UserData> userData = UserData.getById(searchUser.getLongID());
if (!userData.isPresent() || userData.get().getLastStatusChange() == null)
throw new CommandArgumentException("Sorry, I could not find \"" + name + "\".");
cc.replyWith(searchUser.getName() + " has been " + userData.get().getStatus().name().replace("dnd", "do not disturb").toLowerCase() + " since " + format(userData.get().getLastStatusChange()) + '.');
}
Aggregations