-
Notifications
You must be signed in to change notification settings - Fork 8
Description
As much as the server console -> discord feature is wanted (note discord -> server console is in-dependant of this issue)
there are a few issues that need addressing for an efficient implementation.
Biggest issue is size + speed of consoles log, currently discords rate limit globally is:
1. 50 calls per second on all requests to the API
However there is an even stricter rate limit which is the focus of this issue,
2. 5 messages per 5 seconds per channel (TBC, Possibly 10 per 5s)
Also i would like to point out a third limitation that also applies to most implementations.
3. A message cannot be >8mb or >2000 characters in content.
This would clearly get smashed every time the server starts/stops or a stupid plugin that spams more then 4 things a tick (1/20th of a second)
There is a few ways to get around this but I've opened this issue for people to comment on RE these possible implementations before i get round to doing it (after API's finished+tested but probably before 2.0 release)
Possible ways of implementing:
- Bulk Sending
The main concept here is there is a 5s rate limit so all console logs will be stored in memory for 5s then joined by newline and sent as a single message meaning at most server log would be 1 message every 5s (safe from limit 2).
However a limitation to this would be the single message could become >2000 characters (limit 3) a possible way around this is split the last 5s of stored messages into 2000character messages and send the first 4 and store any remaining to the front of the next 5s to be logged.
- Log Files
This ones fairly straight forward fairly recently discords pushed several visual updates one being the ability to view file content in discord without having to download or open the file locally therefor if the servers log was split into say 1min intervals or 5mb or 1hour (etc) we can send a file (<8mb) to discord with that time periods server log and that should be viewable in discord.
- No Log
Simply don't implement a way of sending servers log due to limitations. (don't plan to do this but left it here for peoples opinions)
- Discarding Messages
Once the ratelimit of 2000characters or x messages per second has been hit suffix the message with x messages discarded.
Note this would require timeframes as the plugin cannot see into the future and know how many the server will log in the next second.
- Embed Messages
While embeds are still messages with limit 2 applying they allow for more content but at the cost of formatting.
Limits on embeds:
- Embed titles are limited to 256 characters
- Embed descriptions are limited to 4096 characters
- There can be up to 25 fields
- A field's name is limited to 256 characters and its value to 1024 characters
- The footer text is limited to 2048 characters
- The author name is limited to 256 characters
- The sum of all characters from all embed structures in a message must not exceed 6000 characters