jagrosh / MusicBot

🎶 A Discord music bot that's easy to set up and run yourself!
https://jmusicbot.com
Apache License 2.0
5.36k stars 2.57k forks source link

[Bug Report] Show a relevant error message when trying to use eval with an invalid script enging #1501

Closed ramboozer closed 6 months ago

ramboozer commented 8 months ago

Bug Description

Eval not working Version 0.4.0

Steps to Reproduce

DM or in channel .eval jda.guilds

Expected Result

I expect it to list the servers it in currently in.

Debug Output

`System Properties: java.version = 20.0.1 java.vm.name = Java HotSpot(TM) 64-Bit Server VM java.vm.specification.version = 20 java.runtime.name = Java(TM) SE Runtime Environment java.runtime.version = 20.0.1+9-29 java.specification.version = 20 os.arch = amd64 os.name = Windows 10

JMusicBot Information: Version = 0.4.0 Owner = Prefix = . AltPrefix = null MaxSeconds = 0 NPImages = false SongInStatus = true StayInChannel = true UseEval = true UpdateAlerts = true

Dependency Information: JDA Version = 4.4.1_353 JDA-Utilities Version = 3.0.5 Lavaplayer Version = 727959e9f621fc457b3a5adafcfffb55fdeaa538-SNAPSHOT

Runtime Information: Total Memory = 40 Used Memory = 23

Discord Information: ID = Guilds = 3 Users = 18`

Additional Info

[16:40:19] [ERROR] [JDA]: One of the EventListeners had an uncaught exception java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.put(String, Object)" because "se" is null at com.jagrosh.jmusicbot.commands.owner.EvalCmd.execute(EvalCmd.java:46) at com.jagrosh.jdautilities.command.Command.run(Command.java:323) at com.jagrosh.jdautilities.command.impl.CommandClientImpl.onMessageReceived(CommandClientImpl.java:557) at com.jagrosh.jdautilities.command.impl.CommandClientImpl.onEvent(CommandClientImpl.java:445) at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96) at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88) at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70) at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:160) at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:123) at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36) at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:952) at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:839) at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:817) at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:991) 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)

Checklist

jagrosh commented 8 months ago

This is because you're running java version 20, and the script engine we use was removed by that version. Try installing an older version (ideally 11).

jagrosh commented 8 months ago

Renaming this because a stopgap solution for this is to print an error when attempting to run the eval command instead of only printing a stacktrace to the console.