Closed RickyLaChow closed 1 month ago
The basic answer is, that you got rate limited by discord. This shouldn't happen with discord-webhooks, if you use the right.
Do you use the same webhook client for multiple messages, or do you create new ones constantly?
Some code snippet showing how you sent webhook messages would help a lot here in finding the issue.
It was probably a problem caused by the connection, I have plugins connected via JDA and it said connection refused by Cloudflare (Because now works fine)
Also because I've been sending webhooks for months and I've never had any problems
// example of method i call
public void discordPuliziaSoldiLog(String giocatore, int importo) {
WebhookEmbedBuilder embed =
createEmbed("Pulizia Soldi")
.addField(new WebhookEmbed.EmbedField(false, "Giocatore:", giocatore))
.addField(
new WebhookEmbed.EmbedField(false, "Importo pulito:", String.valueOf(importo)));
sendMessage(embed, discordFile.getString("wash-dirtmoney-logs")); // here i have a discordFile to take webhook url
}
private WebhookEmbedBuilder createEmbed(String title) {
return new WebhookEmbedBuilder()
.setColor(0x0398FC)
.setThumbnailUrl("https://i.imgur.com/p9zAMWi.png")
.setTitle(new WebhookEmbed.EmbedTitle(title, null));
}
private void sendMessage(WebhookEmbedBuilder embed, String url) {
Bukkit.getScheduler()
.runTaskAsynchronously(
plugin,
() -> {
try (WebhookClient client = WebhookClient.withUrl(url)) {
client.send(embed.build());
}
});
}
I'm not entirely sure here, but it seems like you constantly create a new Webhook client to use here... This basically eliminates any ratelimit bucket the client would be aware of... It's always better to keep the client instance somewhere and reuse it when needed.
Mmh, ok but can the problem be that i'm sending too much requests? This appear while i have more than 50 players active and i send a lot of webhooks, for logging a lot of actions from players
Hi, Today, after 23:00, I've encountered problems with my webhooks. They aren't being sent, and I received the following error in the console:
[21:45:42 ERROR]: [club.minnced.discord.webhook.WebhookClient] Encountered 429, retrying after 2285000 ms