use of com.discordbolt.api.command.BotCommand in project BoltBot by DiscordBolt.
the class DisconnectModule method disconnectCommand.
@BotCommand(command = "disconnect", module = "Disconnect Module", description = "Disconnect user(s) from their voice channel.", usage = "Disconnect [User] ", permissions = Permissions.VOICE_MOVE_MEMBERS)
public static void disconnectCommand(CommandContext cc) throws CommandException {
IUser user = UserUtil.findUser(cc.getMessage(), 12);
if (user == null)
throw new CommandArgumentException("The user you specified was unable to be found!");
if (user.getVoiceStateForGuild(cc.getGuild()).getChannel() == null)
throw new CommandStateException("The user you specified is not connected to a voice channel!");
IVoiceChannel temp = cc.getGuild().createVoiceChannel("Disconnect");
user.moveToVoiceChannel(temp);
temp.delete();
cc.getMessage().delete();
}
use of com.discordbolt.api.command.BotCommand in project BoltBot by DiscordBolt.
the class NowPlayingCommand method nowPlayingCommand.
@BotCommand(command = "nowplaying", aliases = { "np", "current", "playing" }, module = MusicModule.MODULE, description = "View what is currently playing", usage = "NowPlaying", allowedChannels = "music")
public static void nowPlayingCommand(CommandContext cc) throws CommandException {
AudioTrack at = MusicModule.getVoiceManager().getNowPlaying(cc.getGuild());
if (at == null)
throw new CommandStateException("Nothing is currently playing. Play something with !Play");
IMessage nowPlayingMessage = cc.replyWith(MusicModule.createPlayingEmbed(cc.getGuild(), MusicModule.getVoiceManager().getNowPlaying(cc.getGuild())));
ChannelUtil.addReaction(nowPlayingMessage, new Emoji[] { EmojiManager.getForAlias(":black_right_pointing_double_triangle_with_vertical_bar:"), EmojiManager.getForAlias(":star:") });
MusicModule.getVoiceManager().putNowPlayingMessage(nowPlayingMessage, MusicModule.getVoiceManager().getNowPlaying(cc.getGuild()));
}
use of com.discordbolt.api.command.BotCommand in project BoltBot by DiscordBolt.
the class PlayCommand method playCommand.
@BotCommand(command = "play", module = MusicModule.MODULE, description = "Queue up the requested song", usage = "Play {URL}", allowedChannels = "music", minArgs = 1, maxArgs = 2)
public static void playCommand(CommandContext cc) throws CommandException {
if (cc.getArgCount() == 1) {
if (!MusicModule.getVoiceManager().isPaused(cc.getGuild()))
throw new CommandStateException("I am not paused!");
MusicModule.getVoiceManager().unpause(cc.getGuild(), cc.getAuthor());
} else {
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), cc.getArgument(1));
cc.replyWith("Your song is now being queued up");
}
}
use of com.discordbolt.api.command.BotCommand in project BoltBot by DiscordBolt.
the class PlayCommand method playPlaylist.
@BotCommand(command = { "play", "-p" }, module = MusicModule.MODULE, description = "Queue up the requested playlist", usage = "Play playlist {number/name}", allowedChannels = "music", minArgs = 2, maxArgs = 100)
public static void playPlaylist(CommandContext cc) throws CommandException {
if (cc.getArgCount() == 2) {
Playlist current = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (current == null)
throw new CommandStateException("You do not have a selected playlist to queue!");
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), current);
cc.replyWith("Your playlist is now being queued and may take ~30 seconds to fully appear in the queue.");
} else {
String playlistRequest = cc.combineArgs(2, cc.getArgCount() - 1);
if (playlistRequest.contains(":")) {
String playlistTitle = playlistRequest.split(":")[0];
String playlistNumber = playlistRequest.split(":")[1];
int songNumber;
try {
songNumber = Integer.valueOf(playlistNumber);
} catch (NumberFormatException e) {
throw new CommandArgumentException("\"" + playlistRequest.split(":")[1] + "\" is not a valid number!");
}
Playlist toPlay = MusicModule.getPlaylistManager().getPlaylist(playlistTitle).orElse(null);
if (toPlay == null)
throw new CommandArgumentException("\"" + playlistTitle + "\" could not be found!");
if (songNumber < 1 || songNumber > toPlay.getSongIDs().size())
throw new CommandArgumentException("\"" + songNumber + "\" is not a valid number for \"" + toPlay.getTitle() + "\"");
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), toPlay.getSongIDs().get(songNumber - 1));
} else {
Playlist toPlay = MusicModule.getPlaylistManager().getPlaylist(playlistRequest).orElse(null);
if (toPlay == null)
throw new CommandArgumentException("\"" + playlistRequest + "\" could not be found!");
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), toPlay);
cc.replyWith("Your playlist is now being queued and may take ~30 seconds to fully appear in the queue.");
}
}
}
use of com.discordbolt.api.command.BotCommand in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistRemoveCommand.
@BotCommand(command = { "playlist", "remove" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "Remove a song from your selected playlist", usage = "Playlist remove [number/URL]", allowedChannels = "music", args = 3)
public static void playlistRemoveCommand(CommandContext cc) throws CommandException {
Playlist selectedPlaylist = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (selectedPlaylist == null)
throw new CommandStateException(NO_PLAYLIST_SELECTED);
if (cc.getArgument(2).matches("^-?\\d+$")) {
selectedPlaylist.removeSong(cc.getAuthor(), Integer.valueOf(cc.getArgument(2)) - 1);
} else {
selectedPlaylist.removeSong(cc.getAuthor(), cc.getArgument(2));
}
cc.replyWith("Successfully removed the song from " + selectedPlaylist.getTitle() + ".");
}
Aggregations