/* * Copyright 2017 John Grosh . * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.jagrosh.jmusicbot.commands.general; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.settings.RepeatMode; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.entities.VoiceChannel; /** * * @author John Grosh */ public class SettingsCmd extends Command { private final static String EMOJI = "\uD83C\uDFA7"; // 🎧 public SettingsCmd(Bot bot) { this.name = "settings"; this.help = "shows the bots settings"; this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = true; } @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.getName() + "**") + "\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.setEmbed(ebuilder.build()).build()).queue(); } }