How do I create a share button on a website for Discord?
Asked Answered
B

2

10

I mean, like a URL that a user can click to open the Discord app or website and prewrite a Discord message, ready to be sent.

I need something similar to mailto: links where I can set the message body text as a parameter or directly within the URL.

Does anything like this exist? Any help would be much appreciated.

Bygone answered 8/5, 2021 at 16:57 Comment(1)
I don´t think there's such a thing currently :/Dniren
P
1

There is no such thing that exists, sorry. You can try to do something with the Discord API but that would lead to many problems with you having to have access to their account in someway that is out of bounds of the normal app authorization.

Petronia answered 24/4, 2023 at 1:39 Comment(0)
J
1

You can use this: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share#examples

It's easy to add with little JS code:

btn.addEventListener("click", async () => {
  try {
    await navigator.share(shareData);
    resultPara.textContent = "MDN shared successfully";
  } catch (err) {
    resultPara.textContent = `Error: ${err}`;
  }
});
Jeuz answered 23/2, 2024 at 16:2 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.