21Joakim/Jockie-Utils

Allow multiple command versions to be defined for one command

Closed this issue · 1 comments

You should be able to add multiple onCommand methods to a command class each with different arguments.

For instance:

public class CommandCopy extends CommandImpl {

	public CommandCopy() {
		super("copy");
	}
	
	public void onCommand(MessageReceivedEvent event, TextChannel channel) {
		channel.createCopy().queue(copy -> {
			event.getChannel().sendMessage("Created copy of channel " + channel.getName()).queue();
		});
	}

	public void onCommand(MessageReceivedEvent event, VoiceChannel channel) {
		channel.createCopy().queue(copy -> {
			event.getChannel().sendMessage("Created copy of channel " + channel.getName()).queue();
		});
	}

	public void onCommand(MessageReceivedEvent event, Role role) {
		role.createCopy().queue(copy -> {
			event.getChannel().sendMessage("Created copy of role " + role.getName()).queue();
		});
	}
}

Problems with this is that the command class does currently not support any way of doing this or anything similar, possible solution to it is to use DummyCommands as done for optional arguments.