use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.
the class PixelHandler method isUnRanked.
public static boolean isUnRanked(long userID, GuildUsers users, IGuild guild) {
ProfileObject user = users.getUserByID(userID);
GuildObject guildObject = Globals.getGuildContent(guild.getLongID());
if (user == null) {
return true;
}
if (guild.getUserByID(userID) == null) {
return true;
}
if (user.getXP() == 0) {
return true;
}
for (UserSetting s : user.getSettings()) {
for (UserSetting test : Constants.dontLogStates) {
if (s == test) {
return true;
}
}
}
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
long diff = now.toEpochSecond() - user.getLastTalked();
long days = TimeUnit.DAYS.convert(diff, TimeUnit.SECONDS);
if (days > 14 && guildObject.config.xpDecay && !user.getSettings().contains(UserSetting.DONT_DECAY)) {
return true;
}
return false;
}
use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.
the class RequestHandler method muteUser.
public static boolean muteUser(long guildID, long userID, boolean isMuting) {
GuildObject content = Globals.getGuildContent(guildID);
IUser user = Globals.getClient().getUserByID(userID);
IGuild guild = Globals.getClient().getGuildByID(guildID);
IRole mutedRole = Globals.client.getRoleByID(content.config.getMutedRoleID());
List<IRole> oldRoles = user.getRolesForGuild(guild);
if (mutedRole != null) {
roleManagement(Globals.getClient().getUserByID(userID), Globals.client.getGuildByID(guildID), mutedRole.getLongID(), isMuting);
List<IRole> newRoles = user.getRolesForGuild(guild);
Globals.getClient().getDispatcher().dispatch(new UserRoleUpdateEvent(guild, user, oldRoles, newRoles));
return true;
}
return false;
}
use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.
the class TimerHandler method dailyMessageHandler.
private static void dailyMessageHandler(TimedEvent event) {
ZonedDateTime timeNow = ZonedDateTime.now(ZoneOffset.UTC);
DayOfWeek day = timeNow.getDayOfWeek();
logger.info("Running Daily tasks for " + day);
Random random = new Random();
for (GuildObject task : Globals.getGuilds()) {
GuildConfig guildconfig = task.config;
// do decay
GuildHandler.dailyTask(task);
// reset offenders
task.resetOffenders();
// getToggles general channel
IChannel generalChannel = task.getChannelByType(ChannelSetting.GENERAL);
// do daily messages
if (generalChannel != null && guildconfig.dailyMessage) {
DailyMessage finalMessage;
List<DailyMessage> messages;
if (event != null && event.doSpecialMessages() && event.getMessagesDay(day).size() != 0) {
messages = event.getMessagesDay(day);
} else {
messages = new ArrayList<>(Globals.getDailyMessages().getDailyMessages(day));
messages.add(Globals.getDailyMessage(day));
}
int randomMessage = random.nextInt(messages.size());
finalMessage = messages.get(randomMessage);
task.config.setLastDailyMessage(finalMessage);
CommandObject command = new CommandObject(task, generalChannel);
RequestHandler.sendMessage(finalMessage.getContents(command), generalChannel);
}
}
}
use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.
the class AnnotationListener method updateVariables.
public static void updateVariables(IGuild guild) {
long guildID = guild.getLongID();
GuildObject guildObject = Globals.getGuildContent(guildID);
guildObject.config.updateVariables(guild);
guildObject.characters.updateVars(guild);
}
use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.
the class AnnotationListener method onUserJoinEvent.
@EventSubscriber
public void onUserJoinEvent(UserJoinEvent event) {
GuildObject content = Globals.getGuildContent(event.getGuild().getLongID());
UserObject user = new UserObject(event.getUser().getLongID(), content);
if (content.config.welcomeMessages && !user.get().isBot()) {
JoinHandler.sendWelcomeMessage(content, event, user);
}
if (content.config.checkNewUsers) {
JoinHandler.checkNewUsers(content, event, user);
}
if (content.config.moduleJoinMessages && content.config.sendJoinMessages) {
JoinHandler.customJoinMessages(content, event.getUser());
}
JoinHandler.autoReMute(event, content, user);
if (!content.config.moduleLogging)
return;
LoggingHandler.doJoinLeaveLog(event, true);
}
Aggregations