Samuel-Maddock / StrawPoll-Java-API

A lightweight Java API Wrapper for StrawPoll.me
MIT License
1 stars 1 forks source link

Getting error on .create() #4

Closed Blade2021 closed 4 years ago

Blade2021 commented 4 years ago

Not sure whats going on here. Using the simplest declaration gives the error as well. I'm using gradle and imported using jitpack as the documentation describes.

StrawPoll strawPoll = new StrawPoll("StrawPoll Title", "Option 1", "Option 2");
strawPoll.create();
java.lang.NullPointerException
    at com.samuelmaddock.strawpollwrapper.StrawPoll.updatePoll(StrawPoll.java:137)
    at com.samuelmaddock.strawpollwrapper.StrawPoll.create(StrawPoll.java:107)
    at rsystems.commands.Poll.onGuildMessageReceived(Poll.java:37)
    at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:394)
    at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
    at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:64)
    at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:165)
    at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:97)
    at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
    at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:877)
    at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:765)
    at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:744)
    at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:915)
    at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
    at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
    at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
    at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
    at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
    at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
    at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
Samuel-Maddock commented 4 years ago

Will check it out, probably a changed endpoint on their end.

Samuel-Maddock commented 4 years ago

Okay I've had a quick look and don't think this is an issue with the library. I seem to be able to create a poll fine by running the code in Example.java file.

I see your using the JDA library, presumably this is stuff running on a Discord bot. See if you can run the code in Example.java to create a poll. Not entirely sure what would have caused your error but it seems to be internal discord API stuff.

Blade2021 commented 4 years ago
Exception in thread "main" java.lang.NullPointerException
    at com.samuelmaddock.strawpollwrapper.StrawPoll.updatePoll(StrawPoll.java:137)
    at com.samuelmaddock.strawpollwrapper.StrawPoll.create(StrawPoll.java:107)
    at Testpackage.Example.main(Example.java:13)

Execution failed for task ':Example.main()'.
> Process 'command 'C:/Program Files/Java/jdk-13.0.1/bin/java.exe'' finished with non-zero exit value 1

This is running inside gradle in a completely separate Java Project with the Example you tagged.

You are correct about the discord bot. Looking to integrate this into it which would be sweet if we can get it working.

Samuel-Maddock commented 4 years ago

Just to double check what version did you install via Gradle? I think the current documentation links you to the Jitpack instructions to v1.0.0 which is broken.

Is your gradle installing the 1.0.4 depository?

For reference, the instructions for 1.0.4 are here

Blade2021 commented 4 years ago

And there it is! That did it. I was indeed building with v1.0.0. Updated to v1.0.4 and everything ran great.

Thanks! Great work!

Samuel-Maddock commented 4 years ago

Great! I have to admit I've never tried using this with Gradle but good to know it works. I'll update the docs to properly link to the 1.0.4 Jitpack instructions.