Skip to content

/audit crashes if more than 10 cases #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zabuzard opened this issue Dec 29, 2021 · 6 comments · Fixed by #472
Closed

/audit crashes if more than 10 cases #335

Zabuzard opened this issue Dec 29, 2021 · 6 comments · Fixed by #472
Assignees
Labels
bug Something isn't working enhance command Modify or improve an existing command or group of commands of the bot good first issue Good for newcomers priority: normal

Comments

@Zabuzard
Copy link
Member

Overview

When using /audit on a user who has more than 10 reported cases, the command crashes with an exception:

Cannot have more than 10 embeds in a message!

8:02:04.098 [pool-2-thread-4] ERROR net.dv8tion.jda.api.requests.RestAction - RestAction queue returned failure
java.lang.IllegalArgumentException: Cannot have more than 10 embeds in a message!
	at net.dv8tion.jda.internal.utils.Checks.check(Checks.java:48) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.WebhookMessageActionImpl.addEmbeds(WebhookMessageActionImpl.java:138) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.entities.AbstractWebhookClient.sendMessageEmbeds(AbstractWebhookClient.java:67) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.entities.AbstractWebhookClient.sendMessageEmbeds(AbstractWebhookClient.java:40) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at org.togetherjava.tjbot.commands.moderation.AuditCommand.lambda$auditUser$5(AuditCommand.java:159) ~[main/:?]
	at net.dv8tion.jda.internal.requests.restaction.operator.FlatMapRestAction.supply(FlatMapRestAction.java:44) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.FlatMapRestAction.lambda$queue$0(FlatMapRestAction.java:54) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.RestActionOperator.doSuccess(RestActionOperator.java:44) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.MapRestAction.lambda$queue$0(MapRestAction.java:41) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.RestActionOperator.doSuccess(RestActionOperator.java:44) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.MapRestAction.lambda$queue$0(MapRestAction.java:41) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.RestActionOperator.doSuccess(RestActionOperator.java:44) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.CombineRestAction.lambda$queue$6(CombineRestAction.java:136) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.api.utils.MiscUtil.locked(MiscUtil.java:146) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.CombineRestAction.lambda$queue$7(CombineRestAction.java:129) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.RestActionOperator.doSuccess(RestActionOperator.java:44) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.MapRestAction.lambda$queue$0(MapRestAction.java:41) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.DeferredRestAction.queue(DeferredRestAction.java:138) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.MapRestAction.queue(MapRestAction.java:41) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.CombineRestAction.queue(CombineRestAction.java:129) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.MapRestAction.queue(MapRestAction.java:41) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.MapRestAction.queue(MapRestAction.java:41) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.FlatMapRestAction.queue(FlatMapRestAction.java:51) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:573) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.api.requests.RestAction.queue(RestAction.java:539) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at org.togetherjava.tjbot.commands.moderation.AuditCommand.auditUser(AuditCommand.java:160) ~[main/:?]
	at org.togetherjava.tjbot.commands.moderation.AuditCommand.onSlashCommand(AuditCommand.java:126) ~[main/:?]
	at org.togetherjava.tjbot.commands.system.CommandSystem.lambda$onSlashCommand$7(CommandSystem.java:121) ~[main/:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: net.dv8tion.jda.api.exceptions.ContextException
	at net.dv8tion.jda.api.exceptions.ContextException.here(ContextException.java:54) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.RestActionOperator.contextWrap(RestActionOperator.java:105) ~[JDA-4.4.0_351.jar:4.4.0_351]
	at net.dv8tion.jda.internal.requests.restaction.operator.FlatMapRestAction.queue(FlatMapRestAction.java:50) ~[JDA-4.4.0_351.jar:4.4.0_351]
	... 8 more

Possible solutions

The cause is quite clear, it attempts to display all cases and then fails cause there are too many. Obviously, this case is not supposed to be triggered really often and its not thaaat big of a deal but we should find at least a solution.

Dyno has pagination support to solve this, so there is an optional option on the command to show page 2, page 3, ... Would probably be a clean solution to do it that way ourselves as well.

@Zabuzard Zabuzard added bug Something isn't working good first issue Good for newcomers enhance command Modify or improve an existing command or group of commands of the bot priority: normal labels Dec 29, 2021
@Zabuzard Zabuzard added this to the Migrate existing commands milestone Dec 29, 2021
@Budbomber
Copy link
Contributor

Budbomber commented Jan 19, 2022

Can I have this one please, It may take a little while, and you may get lots of help requests :) (Didn't realise I could self-Assign!)

@Budbomber Budbomber self-assigned this Jan 19, 2022
@Tais993
Copy link
Member

Tais993 commented Jan 19, 2022

Request help as many times as you can, as long as you do your best we're happy!

@Zabuzard
Copy link
Member Author

Zabuzard commented Jan 19, 2022

Didn't realise I could self-Assign!

You can because you are now "Member of Together-Java/contributors" 🎉

@Budbomber
Copy link
Contributor

Budbomber commented Jan 26, 2022

Zabu, I know you like to tell me not to overcomplicate, however, I have an alternate suggestion for this, and feel it would look better from a design point of view and we can use the embed fields to our benefit, Using 1 - 3 embeds per /audit command, I suggest we stick to the summary first, then the embed something like this :
Type Date & Issuer Reason
WARN 01/05 Mary This
BAN 05/06 Gone

I just feel it would look a lot tidier. See discord for more details :D

@Zabuzard
Copy link
Member Author

I just feel it would look a lot tidier. See discord for more details :D

I see your point but I dislike it. The embeds are really helpful to gain an overview since you can add pictures, color and align things.

That said, I am open for suggestions but lets create another issue for this if u want to change the UI/UX and keep this issue/PR just about fixing the bug (by adding pagination).

@Zabuzard
Copy link
Member Author

@Budbomber Ur coming along well, need help? Should someone take over?

@Taz03 Taz03 assigned Taz03 and unassigned Budbomber Jul 28, 2022
@Taz03 Taz03 mentioned this issue Jul 28, 2022
@Taz03 Taz03 closed this as completed in #472 Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhance command Modify or improve an existing command or group of commands of the bot good first issue Good for newcomers priority: normal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants