use of net.dv8tion.jda.core.entities.Guild in project FlareBot by FlareBot.
the class PlayerListener method onTrackStart.
@Override
public void onTrackStart(AudioPlayer aplayer, AudioTrack atrack) {
FlareBotManager.instance().getLastActive().remove(Long.parseLong(player.getGuildId()));
GuildWrapper wrapper = FlareBotManager.instance().getGuild(player.getGuildId());
if (wrapper.getMusicAnnounceChannelId() != null) {
TextChannel c = Getters.getChannelById(wrapper.getMusicAnnounceChannelId());
if (c != null) {
if (c.getGuild().getSelfMember().hasPermission(c, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
Track track = player.getPlayingTrack();
Queue<Track> playlist = player.getPlaylist();
c.sendMessage(MessageUtils.getEmbed().addField("Now Playing", SongCommand.getLink(track), false).addField("Duration", FormatUtils.formatDuration(track.getTrack().getDuration()), false).addField("Requested by", String.format("<@!%s>", track.getMeta().get("requester")), false).addField("Next up", playlist.isEmpty() ? "Nothing" : SongCommand.getLink(playlist.peek()), false).setImage("https://img.youtube.com/vi/" + track.getTrack().getIdentifier() + "/hqdefault.jpg").build()).queue();
} else {
wrapper.setMusicAnnounceChannelId(null);
}
} else {
wrapper.setMusicAnnounceChannelId(null);
}
}
if (wrapper.isSongnickEnabled()) {
Guild c = wrapper.getGuild();
if (c == null || !GuildUtils.canChangeNick(player.getGuildId())) {
if (!GuildUtils.canChangeNick(player.getGuildId())) {
wrapper.setSongnick(false);
MessageUtils.sendPM(wrapper.getGuild().getOwner().getUser(), "FlareBot can't change it's nickname so SongNick has been disabled!");
}
} else {
Track track = player.getPlayingTrack();
String str = null;
if (track != null) {
str = track.getTrack().getInfo().title;
if (str.length() > 32)
str = str.substring(0, 32);
str = str.substring(0, str.lastIndexOf(' ') + 1);
}
// Even I couldn't make this a one-liner
c.getController().setNickname(c.getSelfMember(), str).queue();
}
}
}
use of net.dv8tion.jda.core.entities.Guild in project TheLighterBot by PhotonBursted.
the class FileController method retrieveDefaultCategories.
private void retrieveDefaultCategories() throws SQLException {
retrieveData("SELECT dc.*\n" + "FROM \"Servers\" AS s\n" + " LEFT JOIN \"DefaultCategories\" AS dc ON dc.server_id = s.discord_id\n" + "WHERE dc.server_id IS NOT NULL", result -> {
try {
Guild g = l.getBot().getGuildById(result.getLong("server_id"));
long entityId = result.getLong("category_id");
Category c = l.getBot().getCategoryById(entityId);
if (g != null && c != null) {
l.getChannelController().getCategories().put(g, c);
}
} catch (SQLException ex) {
log.error("Something went wrong retrieving the default categories", ex);
}
});
}
use of net.dv8tion.jda.core.entities.Guild in project TheLighterBot by PhotonBursted.
the class FileController method retrieveBlacklist.
private void retrieveBlacklist() throws SQLException {
retrieveData("SELECT bl.*\n" + "FROM \"Servers\" AS s\n" + " LEFT JOIN \"Blacklists\" AS bl ON bl.server_id = s.discord_id\n" + "WHERE bl.server_id IS NOT NULL", result -> {
try {
Guild g = l.getBot().getGuildById(result.getLong("server_id"));
long entityId = result.getLong("entity_id");
String entityType = result.getString("entity_type");
switch(entityType) {
case "role":
BannableRole role = new BannableRole(entityId);
if (role.get() != null)
l.getAccesslistController().blacklist(g, role);
break;
case "user":
BannableUser user = new BannableUser(entityId);
if (user.get() != null)
l.getAccesslistController().blacklist(g, user);
break;
default:
}
} catch (SQLException ex) {
log.error("Something went wrong retrieving the blacklist", ex);
}
});
}
Aggregations