MinnDevelopment/discord-webhooks

`org.json.JSONException: JSONObject["url"] not found`

MrPowerGamerBR opened this issue · 2 comments

[[33m[23:53:34.556][[0;39m [[[35mpool-2-thread-1[[0;39m/[[1;31mERROR[[0;39m] [[36mc.m.d.w.WebhookClient[[0;39m: There was some error while sending a webhook message
org.json.JSONException: JSONObject["url"] not found.
        at org.json.JSONObject.get(JSONObject.java:572)
        at org.json.JSONObject.getString(JSONObject.java:859)
        at club.minnced.discord.webhook.receive.EntityFactory.makeEmbedProvider(EntityFactory.java:176)
        at club.minnced.discord.webhook.receive.EntityFactory.makeEmbed(EntityFactory.java:213)
        at club.minnced.discord.webhook.receive.EntityFactory.convertToList(EntityFactory.java:276)
        at club.minnced.discord.webhook.receive.EntityFactory.makeMessage(EntityFactory.java:257)
        at club.minnced.discord.webhook.WebhookClient.executePair(WebhookClient.java:601)
        at club.minnced.discord.webhook.WebhookClient.drainQueue(WebhookClient.java:561)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)

My guess: Seems to be related to webhooks with URLs, all webhooks that I'm sending have Twitch URLs.

How to reproduce:

        val result = built.send(
            WebhookMessageBuilder()
                .append("https://twitch.tv/mrpowergamerbr")
                .setAllowedMentions(AllowedMentions.none())
                .build()
        ).await()

        println(result)
21:23:32.321 [Webhook-RateLimit Thread WebhookID: 847630824718729246] ERROR club.minnced.discord.webhook.WebhookClient - There was some error while sending a webhook message
org.json.JSONException: JSONObject["url"] not found.
	at org.json.JSONObject.get(JSONObject.java:572)
	at org.json.JSONObject.getString(JSONObject.java:859)
	at club.minnced.discord.webhook.receive.EntityFactory.makeEmbedProvider(EntityFactory.java:176)
	at club.minnced.discord.webhook.receive.EntityFactory.makeEmbed(EntityFactory.java:213)
	at club.minnced.discord.webhook.receive.EntityFactory.convertToList(EntityFactory.java:276)
	at club.minnced.discord.webhook.receive.EntityFactory.makeMessage(EntityFactory.java:257)
	at club.minnced.discord.webhook.WebhookClient.executePair(WebhookClient.java:601)
	at club.minnced.discord.webhook.WebhookClient.drainQueue(WebhookClient.java:561)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Exception in thread "main" org.json.JSONException: JSONObject["url"] not found.
	at org.json.JSONObject.get(JSONObject.java:572)
	at org.json.JSONObject.getString(JSONObject.java:859)
	at club.minnced.discord.webhook.receive.EntityFactory.makeEmbedProvider(EntityFactory.java:176)
	at club.minnced.discord.webhook.receive.EntityFactory.makeEmbed(EntityFactory.java:213)
	at club.minnced.discord.webhook.receive.EntityFactory.convertToList(EntityFactory.java:276)
	at club.minnced.discord.webhook.receive.EntityFactory.makeMessage(EntityFactory.java:257)
	at club.minnced.discord.webhook.WebhookClient.executePair(WebhookClient.java:601)
	at club.minnced.discord.webhook.WebhookClient.drainQueue(WebhookClient.java:561)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)

The issue is that webhooks with a Twitch URL doesn't have the url parameter in the embed provider

{"id": "847632083437879366", "type": 0, "content": "https://twitch.tv/mrpowergamerbr", "channel_id": "661387395400466461", "author": {"bot": true, "id": "847630824718729246", "username": "Minn Test", "avatar": null, "discriminator": "0000"}, "attachments": [], "embeds": [{"type": "link", "url": "https://twitch.tv/mrpowergamerbr", "title": "MrPowerGamerBR - Twitch", "description": "Raramente fa\u00e7o lives, mas quando eu fizer, voc\u00ea j\u00e1 sabe aonde me encontrar! \u2022 Criador da Loritta, criador do SparklyPower e de v\u00e1rias outras coisinhas legais! \ud83d\udcab", "provider": {"name": "Twitch"}, "thumbnail": {"url": "https://static-cdn.jtvnw.net/jtv_user_pictures/aaf031f3-8e6e-44bd-8d5d-bbeb68cc353a-profile_image-300x300.png", "proxy_url": "https://images-ext-1.discordapp.net/external/QQthAh575fdHZncUesVb1pQXkFM9Hj-aozjI_yDlkFw/https/static-cdn.jtvnw.net/jtv_user_pictures/aaf031f3-8e6e-44bd-8d5d-bbeb68cc353a-profile_image-300x300.png", "width": 300, "height": 300}}], "mentions": [], "mention_roles": [], "pinned": false, "mention_everyone": false, "tts": false, "timestamp": "2021-05-28T00:27:16.934000+00:00", "edited_timestamp": null, "flags": 0, "components": [], "webhook_id": "847630824718729246"}