Expugn/S-argo

Scout Command Issue

Closed this issue · 7 comments

Bot Version

v2.0

Bug Summary

Over a certain amount of time/scouts/??? the bot will, for some reason, only accept every other scout command. This can be easily corrected by restarting the bot but the origin of the issue is unknown.

How to Reproduce the Issue

Steps to reproduce the issue is unknown. One idea is that it requires a large amount of scouts to be performed. How long the bot is running is not an issue, as one copy bot which has been online for longer than another but less active currently does not have or has ever had this issue.

One issue of the error occuring:

USER 1: `$scout 61 mi` 
BOT: `NOT ENOUGH MEMORY DIAMONDS`
USER 1: `$shop`
BOT: `DISPLAY SHOP MENU`
USER 1: `7`
USER 2: `$profile`
BOT: `DISPLAY PROFILE`
USER 3: `$scout 61 mi` (ERROR OCCURS HERE)
USER 3: `$scout 61 mi`
BOT: `DISPLAY SCOUT RESULT`

Another issue of the error occuring:

USER 1: `$scout 48 mi`
BOT: `DISPLAY SCOUT RESULT`
USER 2: `$scout 48 mi`
BOT: `NOT ENOUGH MEMORY DIAMONDS`
USER 2: `$shop`
BOT: `DISPLAY SHOP MENU`
USER 1: `$scout 48 mi`
USER 2: `7`
USER 2: `$7`
USER 2: `$shop 7 700`
USER 1: `$scout 48 rc` (ERROR OCCURS HERE)
USER 2: `$scout 48 mi`
BOT: `DISPLAY SCOUT RESULT`
USER 1: `$scout 48 rc`
USER 2: `$scout 48 rc`
BOT: `NOT ENOUGH RECORD CRYSTALS`

From the two instances, there's an identical situation. One user tries to scout but lacks the memory diamonds to do so then a second user does the same banner scout.

Well, besides the moment where both users without memory diamonds fail to execute the shop command correctly...

With a given log of the incident, the following exceptions occur:

(when the incident first starts)

Exception in thread "Typing Status Timer" java.lang.UnsupportedOperationException
	at sx.blah.discord.handle.impl.obj.PrivateChannel.isDeleted(PrivateChannel.java:236)
	at sx.blah.discord.handle.impl.obj.Channel$1.run(Channel.java:593)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)

(Afterwards)

12:46:57.255 [Event Dispatcher Handler] ERROR sx.blah.discord.Discord4J - Unhandled exception caught dispatching event MessageReceivedEvent
java.lang.UnsupportedOperationException: null
	at sx.blah.discord.handle.impl.obj.PrivateChannel.getGuild(PrivateChannel.java:166)
	at io.github.spugn.Sargo.CharacterScout.CharacterScout.displayAndSave(CharacterScout.java:517)
	at io.github.spugn.Sargo.CharacterScout.StepUpv2.run(StepUpv2.java:196)
	at io.github.spugn.Sargo.CharacterScout.StepUpv2.<init>(StepUpv2.java:49)
	at io.github.spugn.Sargo.Managers.ScoutManager.<init>(ScoutManager.java:56)
	at io.github.spugn.Sargo.Managers.CommandManager.scoutCommand(CommandManager.java:148)
	at io.github.spugn.Sargo.Managers.CommandManager.<init>(CommandManager.java:86)
	at io.github.spugn.Sargo.Listeners.MessageListener.onMessageReceivedEvent(MessageListener.java:42)
	at sx.blah.discord.api.events.EventDispatcher$MethodEventHandler.handle(EventDispatcher.java:680)
	at sx.blah.discord.api.events.EventDispatcher.lambda$null$17(EventDispatcher.java:610)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
12:47:28.481 [Event Dispatcher Handler] ERROR sx.blah.discord.Discord4J - Unhandled exception caught dispatching event MessageReceivedEvent
java.lang.IllegalStateException: Timer already cancelled.
	at java.util.Timer.sched(Timer.java:397)
	at java.util.Timer.scheduleAtFixedRate(Timer.java:328)
	at sx.blah.discord.handle.impl.obj.Channel.setTypingStatus(Channel.java:607)
	at io.github.spugn.Sargo.Managers.ScoutManager.<init>(ScoutManager.java:38)
	at io.github.spugn.Sargo.Managers.CommandManager.scoutCommand(CommandManager.java:148)
	at io.github.spugn.Sargo.Managers.CommandManager.<init>(CommandManager.java:86)
	at io.github.spugn.Sargo.Listeners.MessageListener.onMessageReceivedEvent(MessageListener.java:42)
	at sx.blah.discord.api.events.EventDispatcher$MethodEventHandler.handle(EventDispatcher.java:680)
	at sx.blah.discord.api.events.EventDispatcher.lambda$null$17(EventDispatcher.java:610)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

From my guess, it would be the changing the Bot's typing status would cause these issues.

A reliable way to reproduce the error is still unknown though.

Pushed out commit 0db39f9 in an attempt to fix the error.

The goal is to keep the changing typing status while removing the issue.
If the changing typing status cannot be fixed then one option is to remove it entirely.

Commit Link

Discord4J pushed out v2.9.3 and one of these changes include "Fixed TypingStatus for Private Channels". This might be what's really causing this scout command issue...

Pushed out commit 377daf2 to see if that'll fix anything, but I'll be keeping the updated code for the first attempted scout command fix because it's probably nicer than what I had before anyways.

It's been about a week and the issue has yet to occur again. I'll consider it resolved.