mercredi 19 avril 2017

Java class add children

I am getting errors with this code. Don't understand where i am wrong. Tried to add a private final command but does not work. Can anyone help me out ??

public class PlayCmd extends MusicCommand {

public PlayCmd(Bot bot)
{
    super(bot);
    this.name = "play";
    this.arguments = "<title|URL|subcommand>";
    this.help = "plays the provided song";
    this.beListening = true;
    this.bePlaying = false;
    this.children = new Command[]{new PlaylistCmd(bot)};
}

@Override
public void doCommand(CommandEvent event) {
    if(event.getArgs().isEmpty())
    {
        StringBuilder builder = new StringBuilder(event.getClient().getWarning()+" Play Commands:\n");
        builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" <song title>` - plays the first result from Youtube");
        builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" <URL>` - plays the provided song, playlist, or stream");
        for(Command cmd: children)
            builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ").append(cmd.getName()).append(" ").append(cmd.getArguments()).append("` - ").append(cmd.getHelp());
        event.reply(builder.toString());
        return;
    }
    String args = event.getArgs().startsWith("<") && event.getArgs().endsWith(">") 
            ? event.getArgs().substring(1,event.getArgs().length()-1) 
            : event.getArgs();
    event.getChannel().sendMessage("\u231A Loading... `["+args+"]`").queue(m -> {
        bot.getAudioManager().loadItemOrdered(event.getGuild(), args, new ResultHandler(m,event,false));
    });
}






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire