Java JDA 如何检查消息是否超过 2 周
Java JDA How to make check if the messsage is older than 2 weeks
我的 discord bot 的清除聊天命令有问题,当消息超过 2 周时,我遇到了这个问题。我怎样才能检查?我的意思是,如果他们超过 2 周,我如何才能在频道中发送随机消息而不是显示此错误?
[JDA MainWS-ReadThread] ERROR net.dv8tion.jda.api.JDA - One of the EventListeners had an uncaught exception
java.lang.IllegalArgumentException: Message Id provided was older than 2 weeks. Id: 756212215564206290
at net.dv8tion.jda.internal.utils.Checks.check(Checks.java:43)
at net.dv8tion.jda.internal.entities.TextChannelImpl.deleteMessagesByIds(TextChannelImpl.java:140)
at net.dv8tion.jda.internal.entities.TextChannelImpl.deleteMessages(TextChannelImpl.java:125)
at cf.lionsquad.lionminus.command.impl.ClearCommand.execute(ClearCommand.java:68)
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:82)
at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:69)
at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:150)
at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:122)
at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:948)
at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:835)
at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:813)
at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:986)
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)
我还检查了是否没有指定数量的消息删除(如果它的 /clear 0 或只是 /clear):
if (amount < 0) {
this.incorrectArgument(event, 0, args[0]);
return;
}
存在一种名为event.getMessage().getTimeCreated();
的方法
但在您清除这些消息的情况下不会发生这种情况。
我的 discord bot 的清除聊天命令有问题,当消息超过 2 周时,我遇到了这个问题。我怎样才能检查?我的意思是,如果他们超过 2 周,我如何才能在频道中发送随机消息而不是显示此错误?
[JDA MainWS-ReadThread] ERROR net.dv8tion.jda.api.JDA - One of the EventListeners had an uncaught exception
java.lang.IllegalArgumentException: Message Id provided was older than 2 weeks. Id: 756212215564206290
at net.dv8tion.jda.internal.utils.Checks.check(Checks.java:43)
at net.dv8tion.jda.internal.entities.TextChannelImpl.deleteMessagesByIds(TextChannelImpl.java:140)
at net.dv8tion.jda.internal.entities.TextChannelImpl.deleteMessages(TextChannelImpl.java:125)
at cf.lionsquad.lionminus.command.impl.ClearCommand.execute(ClearCommand.java:68)
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:82)
at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:69)
at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:150)
at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:122)
at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:948)
at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:835)
at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:813)
at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:986)
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)
我还检查了是否没有指定数量的消息删除(如果它的 /clear 0 或只是 /clear):
if (amount < 0) {
this.incorrectArgument(event, 0, args[0]);
return;
}
存在一种名为event.getMessage().getTimeCreated();
的方法
但在您清除这些消息的情况下不会发生这种情况。