use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.
the class ServerLogHandler method getLogChannel.
private static TextChannel getLogChannel(Guild guild) {
String entry = new ServerLogSQL(guild).get("channel");
if (entry == null)
return null;
if (entry.equals("0"))
return null;
TextChannel textChannel;
try {
textChannel = guild.getTextChannelById(entry);
return textChannel;
} catch (NullPointerException ignored) {
// channel deleted or something
}
return null;
}
use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.
the class UserJoinListener method onGuildMemberJoin.
public void onGuildMemberJoin(GuildMemberJoinEvent e) {
try {
String joinMessage = RubiconBot.getMySQL().getGuildValue(e.getGuild(), "joinmsg");
if (joinMessage.equals("0")) {
return;
} else {
TextChannel messageChannel = e.getJDA().getTextChannelById(RubiconBot.getMySQL().getGuildValue(e.getGuild(), "channel"));
if (messageChannel == null)
return;
joinMessage = joinMessage.replace("%user%", e.getMember().getAsMention());
joinMessage = joinMessage.replace("%guild%", e.getGuild().getName());
messageChannel.sendMessage(joinMessage).queue();
}
} catch (NullPointerException ex) {
// Channel does not exits
}
UserSQL userSQL = new UserSQL(e.getUser());
CommandPremium.assignPremiumRole(userSQL);
}
use of net.dv8tion.jda.core.entities.TextChannel 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 net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.
the class CommandWhitelist method executeAdd.
private void executeAdd(String[] args, Member member, Guild guild, TextChannel textChannel, Message message) {
if (message.getMentionedChannels().isEmpty()) {
SafeMessage.sendMessage(textChannel, EmbedUtil.error("Unknown usage", "Please use `rc!whitelist add <#Channel>`").build(), 7);
return;
}
TextChannel channel = message.getMentionedChannels().get(0);
if (RubiconBot.getMySQL().isChannelWhitelisted(channel)) {
SafeMessage.sendMessage(textChannel, EmbedUtil.info("Already whitelisted", "This channel is already whitelisted").build());
return;
}
String oldEntry = RubiconBot.getMySQL().getGuildValue(guild, "whitelist");
String newEntry;
if (oldEntry.equals(""))
newEntry = channel.getId();
else
newEntry = oldEntry + "," + channel.getId();
RubiconBot.getMySQL().updateGuildValue(guild, "whitelist", newEntry);
SafeMessage.sendMessage(textChannel, EmbedUtil.success("Successfully whitelisted channel", "Successfully whitelisted channel `" + channel.getName() + "` !").build(), 5);
}
use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.
the class CommandWhitelist method executeList.
private void executeList(String[] args, Member member, Guild guild, TextChannel textChannel) {
if (whitelistEnabled(guild)) {
List<String> channelIDs = Arrays.asList(RubiconBot.getMySQL().getGuildValue(guild, "whitelist").split(","));
StringBuilder channels = new StringBuilder();
channelIDs.forEach(id -> {
try {
TextChannel channel = guild.getTextChannelById(id);
channels.append(channel.getName()).append(", ");
} catch (NullPointerException ignored) {
String oldEntry = RubiconBot.getMySQL().getGuildValue(guild, "whitelist");
String newEntry = oldEntry.replace(id, "");
if (newEntry.contains(","))
newEntry = new StringBuilder(newEntry).replace(newEntry.lastIndexOf(","), newEntry.lastIndexOf(",") + 1, "").toString();
RubiconBot.getMySQL().updateGuildValue(guild, "whitelist", newEntry);
if (channelIDs.size() == 0) {
SafeMessage.sendMessage(textChannel, EmbedUtil.info("Blacklisted Channels", "Whitelist mode: `" + String.valueOf(whitelistEnabled(guild)).replace("true", "enabled").replace("false", "disabled") + "`").build());
return;
}
}
});
channels.replace(channels.lastIndexOf(","), channels.lastIndexOf(",") + 1, "");
SafeMessage.sendMessage(textChannel, EmbedUtil.info("Whitelisted channels", "Whitelist mode: `" + String.valueOf(whitelistEnabled(guild)).replace("true", "enabled").replace("false", "disabled") + "`\nChannels: `" + channels.toString() + "`").build());
} else
SafeMessage.sendMessage(textChannel, EmbedUtil.info("Whitelisted channels", "Whitelist mode: `" + String.valueOf(whitelistEnabled(guild)).replace("true", "enabled").replace("false", "disabled") + "`").build());
}
Aggregations