use of fun.rubicon.sql.GuildSQL in project Rubicon by Rubicon-Bot.
the class CommandManager method onMessageReceived.
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot())
return;
if (event.isFromType(ChannelType.PRIVATE))
return;
GuildSQL guildSQL = GuildSQL.fromGuild(event.getGuild());
if (guildSQL.enabledBlacklist())
if (guildSQL.isBlacklisted(event.getTextChannel()))
return;
else if (guildSQL.enabledWhitelist())
if (!guildSQL.isWhitelisted(event.getTextChannel()))
return;
MusicManager.handleTrackChoose(event);
super.onMessageReceived(event);
ParsedCommandInvocation commandInvocation = parse(event.getMessage());
// Send typing because it's useless
if (commandInvocation != null && !event.getAuthor().isBot() && !event.getAuthor().isFake() && !event.isWebhookMessage()) {
if (GlobalBlacklist.isOnBlacklist(event.getAuthor())) {
event.getTextChannel().sendMessage(EmbedUtil.message(EmbedUtil.error("Blacklisted", "You are on the RubiconBot blacklist! ;)"))).queue(msg -> msg.delete().queueAfter(20, TimeUnit.SECONDS));
return;
}
call(commandInvocation);
}
}
use of fun.rubicon.sql.GuildSQL in project Rubicon by Rubicon-Bot.
the class CommandBlacklist method executeRemove.
private void executeRemove(String[] args, Member member, Guild guild, TextChannel textChannel, Message message) {
GuildSQL sql = GuildSQL.fromGuild(guild);
if (message.getMentionedChannels().isEmpty()) {
SafeMessage.sendMessage(textChannel, EmbedUtil.error("Unknown usage", "Please use `rc!blacklist add <#Channel>`").build(), 7);
return;
}
TextChannel channel = message.getMentionedChannels().get(0);
if (!sql.isBlacklisted(channel)) {
SafeMessage.sendMessage(textChannel, EmbedUtil.info("Not blacklisted", "This channel is not blacklisted").build());
return;
}
String oldEntry = RubiconBot.getMySQL().getGuildValue(guild, "blacklist");
String newEntry;
if (oldEntry.equals(channel.getId()))
newEntry = "";
else
newEntry = oldEntry.replace(channel.getId(), "");
if (newEntry.contains(","))
newEntry = new StringBuilder(newEntry).replace(newEntry.lastIndexOf(","), newEntry.lastIndexOf(",") + 1, "").toString();
RubiconBot.getMySQL().updateGuildValue(guild, "blacklist", newEntry);
SafeMessage.sendMessage(textChannel, EmbedUtil.success("Successfully removed channel from blacklist", "Successfully removed channel `" + channel.getName() + "` from blacklist!").build(), 5);
}
use of fun.rubicon.sql.GuildSQL in project Rubicon by Rubicon-Bot.
the class CommandBlacklist method handleTextChannelDeletion.
public static void handleTextChannelDeletion(TextChannelDeleteEvent event) {
GuildSQL sql = GuildSQL.fromGuild(event.getGuild());
if (sql.isBlacklisted(event.getChannel())) {
String oldEntry = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "blacklist");
String newEntry = oldEntry.replace(event.getChannel().getId(), "");
if (newEntry.contains(","))
newEntry = new StringBuilder(newEntry).replace(newEntry.lastIndexOf(","), newEntry.lastIndexOf(",") + 1, "").toString();
RubiconBot.getMySQL().updateGuildValue(event.getGuild(), "blacklist", newEntry);
}
}
use of fun.rubicon.sql.GuildSQL in project Rubicon by Rubicon-Bot.
the class CommandWhitelist method handleTextChannelDeletion.
public static void handleTextChannelDeletion(TextChannelDeleteEvent event) {
GuildSQL sql = GuildSQL.fromGuild(event.getGuild());
if (sql.isBlacklisted(event.getChannel())) {
String oldEntry = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "whitelist");
String newEntry = oldEntry.replace(event.getChannel().getId(), "");
if (newEntry.contains(","))
newEntry = new StringBuilder(newEntry).replace(newEntry.lastIndexOf(","), newEntry.lastIndexOf(",") + 1, "").toString();
RubiconBot.getMySQL().updateGuildValue(event.getGuild(), "whitelist", newEntry);
}
}
Aggregations