Infinite Loop

Good morning/afternoon/evening Java Programmers! I hope all is well with you all! I currently am bringing to you guys a concern that I have with my code. I was wondering if someone could help me understand what is happening here. Context: I currently am making a chat filter on a discord bot. Within this chat filter I have listed a bunch of unwanted strings within an array "String[] badWords...". So within this array I want to practically ignore any case sensitivity going on within our listed strings. By doing this I iterate through each string in the array and then proceed to iterate through each character in the string sequence to check for any upper case or lower case characters. Then once there has been characters found in a message then I want the discord bot to delete the message. Thing is...the code works just how I want it to right? It checks for each sequence...then deletes the message as normal. However...it gives off an error message in our console that does not help me get to where the real issue is. Unfortunately discord bot API (JDA) does not inform me of the specifics of what I need to look for. However I feel as if i have failed java knowledge by not knowing this would create an infinite loop here. If this is accurate however and my code seems to work perfectly fine from your eyes then please let me know. I will do my best to look deeper into the JDA (Discord Bot API) to see what I can change up to make it better or to stop this infinite loop from happening.
No description
No description
No description
8 Replies
JavaBot
JavaBot11mo ago
This post has been reserved for your question.
Hey @Jordan σ_σ! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Jordan σ_σ
Jordan σ_σOP11mo ago
So after further investigation...i noticed that when i was iterating through each character through the strings in our array...the delete method was occuring in the context of it deleting/attempting to delete going through each and every character in the array! So now my next question would be is there a way to only allow this delete method to occur even if there are uppercase/lowercase characters??
JavaBot
JavaBot11mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
The Typhothanian
The Typhothanian11mo ago
I would recommend having the String[] be all lowercase and call (message content string).toLowerCase().contains(bad word)
Jordan σ_σ
Jordan σ_σOP11mo ago
so make the strings either lowercase or uppercase before delete?
The Typhothanian
The Typhothanian11mo ago
Either, they just need to be the same format
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot11mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?