Discord Parameter example incomplete
avluis opened this issue · 3 comments
avluis commented
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
.
Bastian commented
Hey, thank you.
The example should work fine - if it doesn't I messed up something with JDA. I'll check it.
hgjkant commented
I have found the same. Arguments of type Channel
and Message
are null.