@@ -11,15 +11,20 @@ class Discord extends Adapter
1111 protected const NAME = 'Discord ' ;
1212 protected const TYPE = 'chat ' ;
1313 protected const MESSAGE_TYPE = DiscordMessage::class;
14+ protected string $ webhookId = '' ;
1415
1516 /**
16- * @param string $webhookId Your Discord webhook ID.
17- * @param string $webhookToken Your Discord webhook token.
17+ * @param string $webhookURL Your Discord webhook URL.
1818 */
1919 public function __construct (
20- private string $ webhookId ,
21- private string $ webhookToken ,
20+ private string $ webhookURL
2221 ) {
22+ $ parts = explode ('/webhooks/ ' , $ webhookURL );
23+ if (count ($ parts ) >= 2 ) {
24+ $ webhookParts = explode ('/ ' , $ parts [1 ]);
25+ $ this ->webhookId = $ webhookParts [0 ];
26+ }
27+
2328 }
2429
2530 public function getName (): string
@@ -69,7 +74,7 @@ protected function process(DiscordMessage $message): array
6974 $ response = new Response ($ this ->getType ());
7075 $ result = $ this ->request (
7176 method: 'POST ' ,
72- url: "https://discord.com/api/webhooks/ {$ this ->webhookId } / { $ this -> webhookToken }{$ queryString }" ,
77+ url: "{$ this ->webhookURL }{$ queryString }" ,
7378 headers: [
7479 'Content-Type: application/json ' ,
7580 ],
0 commit comments