Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.savvy.melodybot.cmds;
- import com.jagrosh.jdautilities.command.Command;
- import com.jagrosh.jdautilities.command.CommandEvent;
- import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
- import me.savvy.melodybot.music.AudioHandler;
- import me.savvy.melodybot.music.MusicManager;
- import me.savvy.melodybot.music.MusicModule;
- import me.savvy.melodybot.music.RadioStations;
- import me.savvy.melodybot.music.ResultHandler;
- import net.dv8tion.jda.api.EmbedBuilder;
- import net.dv8tion.jda.api.JDA;
- import net.dv8tion.jda.api.entities.Guild;
- import net.dv8tion.jda.api.entities.Member;
- import net.dv8tion.jda.api.entities.VoiceChannel;
- import net.dv8tion.jda.api.managers.AudioManager;
- import java.awt.*;
- public class RadioCommand extends Command {
- private final MusicManager manager;
- public RadioCommand(MusicManager manager) {
- this.manager = manager;
- this.name = "radio";
- this.help = "Radio command";
- this.guildOnly = true;
- }
- @Override
- protected void execute(CommandEvent commandEvent) {
- Member member = commandEvent.getMember();
- JDA jda = commandEvent.getJDA();
- if (member.getVoiceState() == null || !member.getVoiceState().inVoiceChannel()) {
- EmbedBuilder eb = new EmbedBuilder();
- eb.setDescription(member.getAsMention() + " You must be in a voice channel to use this command!");
- eb.setColor(Color.decode("#FF6B68"));
- commandEvent.reply(eb.build());
- return;
- }
- if (commandEvent.getArgs().isEmpty()) {
- EmbedBuilder eb = new EmbedBuilder();
- try {
- eb.setTitle(jda.getEmoteById("688147785610035335").getAsMention() + " Please specify a radio station " + jda.getEmoteById("688147785610035335").getAsMention());
- } catch(NullPointerException ignored) {}
- eb.setColor(Color.decode("#CB1450"));
- eb.addField(
- "\uD83C\uDDEC\uD83C\uDDE7 UK Radio Station's",
- "CAPITALFM LIVERPOOL"
- + "\n" +
- "CAPITALFM LONDON"
- + "\n" +
- "CAPITALFM XTRA"
- + "\n" +
- "HEART"
- + "\n" +
- "3FM",
- true);
- eb.addField(
- "\uD83C\uDDE6\uD83C\uDDFA Australia Radio Station's",
- "2GB"
- + "\n" +
- "HIT 92.9 PERTH"
- + "\n" +
- "FOX 101.9",
- true);
- eb.addField(
- "\uD83C\uDDF3\uD83C\uDDF1 Dutch Radio Station's",
- "SkyRadio"
- + "\n" +
- "RADIO538"
- + "\n" +
- "Qmusic",
- true);
- eb.addField(
- "If you would like a Radio Station added please join our Discord and @HΞLIX#0420 in \n \uD83D\uDCAC-gossiping Thank you.\n\n Server Invite > http://discord.melody-bot.xyz/",
- "", false);
- commandEvent.reply(eb.build());
- return;
- }
- RadioStations station = RadioStations.getStation(commandEvent.getArgs());
- if (station == null) {
- commandEvent.reply("That station does not exist.");
- return;
- }
- Guild guild = commandEvent.getGuild();
- AudioManager audioManager = guild.getAudioManager();
- AudioHandler audioHandler = (AudioHandler) audioManager.getSendingHandler();
- if (guild.getSelfMember().getVoiceState() != null ||
- !guild.getSelfMember().getVoiceState().inVoiceChannel()) {
- VoiceChannel voiceChannel = member.getVoiceState().getChannel();
- audioManager.openAudioConnection(voiceChannel);
- }
- MusicModule module = manager.getData().get(guild.getId());
- AudioPlayerManager playerManager = module.getManager();
- assert audioHandler != null;
- audioHandler.playRadio(station.getStationURL());
- playerManager.loadItemOrdered(guild, station.getStationURL(),
- new ResultHandler(audioHandler, member.getUser(), commandEvent));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement