1
votes

I am wondering if there is a way I can communicate using my HTML/PHP website to communicate with my discord bot. So what I want to do is to have some code or use another sollution to send messages to be sent by my discord bot. So for example: Lets say I write a line I want to be sent from my website every time someone submits a form, I then want a message to be sent by the discord bot saying something simular to "XXXX just submitted a form" in a specific channel.

I have tried seaching through youtube, stack overflow and other websites but didnt find a way to do it.

I already have the discord bot and its running using Visual Studio Code. I also have the website running.

Just wondering if theres a way to do this.

1
Check out Webhooks in Discord. If you're looking for communication directly with the client and a Webhook wouldn't work, you should do some research on WebSockets.slothiful

1 Answers

1
votes

The solution to this is to use a webhook and download the extension CURL. Then do this in the PHP code:

$curl = curl_init("DISCORD API FOR WEBHOOK");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("content" => "MESSAGE")));
curl_exec($curl);