use of com.jagrosh.jmusicbot.settings.Settings in project MusicBot by jagrosh.
the class AutoplaylistCmd method execute.
@Override
public void execute(CommandEvent event) {
if (event.getArgs().isEmpty()) {
event.reply(event.getClient().getError() + " Please include a playlist name or NONE");
return;
}
if (event.getArgs().equalsIgnoreCase("none")) {
Settings settings = event.getClient().getSettingsFor(event.getGuild());
settings.setDefaultPlaylist(null);
event.reply(event.getClient().getSuccess() + " Cleared the default playlist for **" + event.getGuild().getName() + "**");
return;
}
String pname = event.getArgs().replaceAll("\\s+", "_");
if (bot.getPlaylistLoader().getPlaylist(pname) == null) {
event.reply(event.getClient().getError() + " Could not find `" + pname + ".txt`!");
} else {
Settings settings = event.getClient().getSettingsFor(event.getGuild());
settings.setDefaultPlaylist(pname);
event.reply(event.getClient().getSuccess() + " The default playlist for **" + event.getGuild().getName() + "** is now `" + pname + "`");
}
}
use of com.jagrosh.jmusicbot.settings.Settings in project MusicBot by jagrosh.
the class VolumeCmd method doCommand.
@Override
public void doCommand(CommandEvent event) {
AudioHandler handler = (AudioHandler) event.getGuild().getAudioManager().getSendingHandler();
Settings settings = event.getClient().getSettingsFor(event.getGuild());
int volume = handler.getPlayer().getVolume();
if (event.getArgs().isEmpty()) {
event.reply(FormatUtil.volumeIcon(volume) + " Current volume is `" + volume + "`");
} else {
int nvolume;
try {
nvolume = Integer.parseInt(event.getArgs());
} catch (NumberFormatException e) {
nvolume = -1;
}
if (nvolume < 0 || nvolume > 150)
event.reply(event.getClient().getError() + " Volume must be a valid integer between 0 and 150!");
else {
handler.getPlayer().setVolume(nvolume);
settings.setVolume(nvolume);
event.reply(FormatUtil.volumeIcon(nvolume) + " Volume changed from `" + volume + "` to `" + nvolume + "`");
}
}
}
use of com.jagrosh.jmusicbot.settings.Settings in project MusicBot by jagrosh.
the class SettingsCmd method execute.
@Override
protected void execute(CommandEvent event) {
Settings s = event.getClient().getSettingsFor(event.getGuild());
MessageBuilder builder = new MessageBuilder().append(EMOJI + " **").append(FormatUtil.filter(event.getSelfUser().getName())).append("** settings:");
TextChannel tchan = s.getTextChannel(event.getGuild());
VoiceChannel vchan = s.getVoiceChannel(event.getGuild());
Role role = s.getRole(event.getGuild());
EmbedBuilder ebuilder = new EmbedBuilder().setColor(event.getSelfMember().getColor()).setDescription("Text Channel: " + (tchan == null ? "Any" : "**#" + tchan.getName() + "**") + "\nVoice Channel: " + (vchan == null ? "Any" : vchan.getAsMention()) + "\nDJ Role: " + (role == null ? "None" : "**" + role.getName() + "**") + "\nCustom Prefix: " + (s.getPrefix() == null ? "None" : "`" + s.getPrefix() + "`") + "\nRepeat Mode: " + (s.getRepeatMode() == RepeatMode.OFF ? s.getRepeatMode().getUserFriendlyName() : "**" + s.getRepeatMode().getUserFriendlyName() + "**") + "\nDefault Playlist: " + (s.getDefaultPlaylist() == null ? "None" : "**" + s.getDefaultPlaylist() + "**")).setFooter(event.getJDA().getGuilds().size() + " servers | " + event.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count() + " audio connections", null);
event.getChannel().sendMessage(builder.setEmbeds(ebuilder.build()).build()).queue();
}
use of com.jagrosh.jmusicbot.settings.Settings in project MusicBot by jagrosh.
the class NowplayingHandler method updateTopic.
public void updateTopic(long guildId, AudioHandler handler, boolean wait) {
Guild guild = bot.getJDA().getGuildById(guildId);
if (guild == null)
return;
Settings settings = bot.getSettingsManager().getSettings(guildId);
TextChannel tchan = settings.getTextChannel(guild);
if (tchan != null && guild.getSelfMember().hasPermission(tchan, Permission.MANAGE_CHANNEL)) {
String otherText;
String topic = tchan.getTopic();
if (topic == null || topic.isEmpty())
otherText = "\u200B";
else if (topic.contains("\u200B"))
otherText = topic.substring(topic.lastIndexOf("\u200B"));
else
otherText = "\u200B\n " + topic;
String text = handler.getTopicFormat(bot.getJDA()) + otherText;
if (!text.equals(tchan.getTopic())) {
try {
// normally here if 'wait' was false, we'd want to queue, however,
// new discord ratelimits specifically limiting changing channel topics
// mean we don't want a backlog of changes piling up, so if we hit a
// ratelimit, we just won't change the topic this time
tchan.getManager().setTopic(text).complete(wait);
} catch (PermissionException | RateLimitedException ignore) {
}
}
}
}
use of com.jagrosh.jmusicbot.settings.Settings in project MusicBot by jagrosh.
the class DJCommand method checkDJPermission.
public static boolean checkDJPermission(CommandEvent event) {
if (event.getAuthor().getId().equals(event.getClient().getOwnerId()))
return true;
if (event.getGuild() == null)
return true;
if (event.getMember().hasPermission(Permission.MANAGE_SERVER))
return true;
Settings settings = event.getClient().getSettingsFor(event.getGuild());
Role dj = settings.getRole(event.getGuild());
return dj != null && (event.getMember().getRoles().contains(dj) || dj.getIdLong() == event.getGuild().getIdLong());
}
Aggregations