use of ml.duncte123.skybot.Variables in project SkyBot by DuncteBot.
the class MessageListener method doAutoModChecks.
private boolean doAutoModChecks(@Nonnull GuildMessageReceivedEvent event, GuildSetting settings, String raw) {
final Guild guild = event.getGuild();
if (guild.getSelfMember().hasPermission(Permission.MESSAGE_MANAGE) && !Objects.requireNonNull(event.getMember()).hasPermission(Permission.MESSAGE_MANAGE)) {
checkMessageForInvites(guild, event, settings, raw);
final Message messageToCheck = event.getMessage();
final DunctebotGuild dbG = new DunctebotGuild(event.getGuild(), variables);
if (blacklistedWordCheck(dbG, messageToCheck, event.getMember(), settings.getBlacklistedWords())) {
return true;
}
if (checkSwearFilter(messageToCheck, event, dbG)) {
return true;
}
checkSpamFilter(messageToCheck, event, settings, dbG);
}
return false;
}
use of ml.duncte123.skybot.Variables in project SkyBot by DuncteBot.
the class SQLiteTimers method checkUnbansAndUnmutes.
private static void checkUnbansAndUnmutes(Variables variables) {
variables.getDatabaseAdapter().getExpiredBansAndMutes((bans, mutes) -> {
final DatabaseAdapter adapter = variables.getDatabaseAdapter();
handleUnban(bans, adapter, variables);
handleUnmute(mutes, adapter, variables);
return null;
});
}
use of ml.duncte123.skybot.Variables in project SkyBot by DuncteBot.
the class MessageListener method onGuildMessageDelete.
protected void onGuildMessageDelete(final GuildMessageDeleteEvent event) {
this.handlerThread.submit(() -> {
try {
final DunctebotGuild guild = new DunctebotGuild(event.getGuild(), variables);
if (!guild.getSettings().isMessageLogging()) {
// just delete the message here as we don't want to keep it around
this.redis.deleteMessage(event.getMessageId());
return;
}
final MessageData data = this.redis.getAndDeleteMessage(event.getMessageId());
if (data != null) {
this.logDeletedMessage(data, guild);
}
} catch (Exception e) {
LOGGER.error("Exception on message delete", e);
}
});
}
use of ml.duncte123.skybot.Variables in project SkyBot by duncte123.
the class CommandManager method runCustomCommand.
private void runCustomCommand(ICommand cmd, String invoke, List<String> args, GuildMessageReceivedEvent event) {
final CustomCommand cusomCommand = (CustomCommand) cmd;
if (cusomCommand.getGuildId() != event.getGuild().getIdLong()) {
return;
}
try {
MDC.put("command.custom.message", cusomCommand.getMessage());
final Parser parser = CommandUtils.getParser(new CommandContext(invoke, args, event, variables));
final String message = parser.parse(cusomCommand.getMessage());
final MessageConfig.Builder messageBuilder = MessageConfig.Builder.fromEvent(event);
final DataObject object = parser.get("embed");
boolean hasContent = false;
if (!message.isEmpty()) {
messageBuilder.setMessage("\u200B" + message);
hasContent = true;
}
if (object != null) {
final JDAImpl jda = (JDAImpl) event.getJDA();
final EmbedBuilder embed = new EmbedBuilder(jda.getEntityBuilder().createMessageEmbed(object));
messageBuilder.addEmbed(true, embed);
hasContent = true;
}
if (hasContent) {
sendMsg(messageBuilder.build());
}
parser.clear();
} catch (Exception e) {
sendMsg(MessageConfig.Builder.fromEvent(event).setMessage("Error with parsing custom command: " + e.getMessage()).build());
Sentry.captureException(e);
}
}
use of ml.duncte123.skybot.Variables in project SkyBot by duncte123.
the class CommandManager method runNormalCommand.
private void runNormalCommand(ICommand cmd, String invoke, List<String> args, GuildMessageReceivedEvent event) {
if (cmd.getCategory() == CommandCategory.NSFW && this.isSafeForWork(event)) {
sendMsg(MessageConfig.Builder.fromEvent(event).setMessage("Woops, this channel is not marked as NSFW.\n" + "Please mark this channel as NSFW to use this command").build());
return;
}
MDC.put("command.class", cmd.getClass().getName());
LOGGER.info("Dispatching command \"{}\" in guild \"{}\" with {}", cmd.getClass().getSimpleName(), event.getGuild(), args);
cmd.executeCommand(new CommandContext(invoke, args, event, variables));
}
Aggregations