Bastian/sdcf4j

Discord Parameter example incomplete

avluis opened this issue · 3 comments

First off, great library you have here -- I've been looking for something that emulates Discord.Net.Commands for Java.

On to the issue -- your example of a dynamic command (I'm using JDA) is a bit incomplete:

@Command(aliases = {"!channelInfo", "!ci"}, description = "Pong!", async = true, privateMessages = false)
public String onCommand(Channel channel) {
    return "You are in channel #" + channel.getName() + " with id " + channel.getId();
}

As is, you will encounter a NullPointerException as it won't be able to resolve Channel -- this works instead:

@Command(aliases = {"!channelInfo", "!ci"}, description = "Pong!", async = true, privateMessages = false)
public String onCommand(MessageReceivedEvent event) {
    Channel channel = event.getTextChannel();
    return "You are in channel #" + channel.getName() + " with id " + channel.getId();
}

I've only tested with JDA, so I cannot speak for the other libraries -- this is under JDA 2.2.1_353.

Hey, thank you.
The example should work fine - if it doesn't I messed up something with JDA. I'll check it.

I have found the same. Arguments of type Channel and Message are null.

Fixed in 1.0.3
See 39c363b