Exiled-Team / DiscordIntegration

GNU General Public License v3.0
13 stars 36 forks source link

Fix message spam #116

Closed PintTheDragon closed 1 year ago

PintTheDragon commented 2 years ago

This PR should fix the message spam that sometimes happens. It seems like the issue was caused by DI incorrectly constructing a substring, then removing the substring from the initial message and adding it back. Because the substring was invalid, the entire initial message was added back which caused it to keep sending.

This PR makes sure that the substring is created correctly, and uses Substring instead of Replace, which should be a bit more performant but also makes it impossible for this issue to happen again (at least in this area) as part of the string will always be removed.

PintTheDragon commented 2 years ago

This PR does not fix another issue where if the first line of a message is > 1900 (which if any line is, it will eventually be the first line), the discord API will reject it or it will leak memory.