GetDiscordRichPresenceUserID: Difference between revisions
Jump to navigation
Jump to search
Fernando187 (talk | contribs) m (fix nightly version that introduced this to 22342) |
Fernando187 (talk | contribs) m (minor text edits) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{Important Note|The function will correctly | {{Important Note|The function will correctly return the UserID if the user has given consent beforehand and is connected to the Rich Presence application.}} | ||
{{New feature/item|3.0161|1.6.0|22342| | {{New feature/item|3.0161|1.6.0|22342| | ||
The function returns the client Discord UserID. | The function returns the client Discord UserID. | ||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
This example displays the user's userid in the chat | This example displays the user's userid in the chat if they have granted permission to share data. Otherwise, they will receive an appropriate message. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addCommandHandler("getmyuserid", | addCommandHandler("getmyuserid", | ||
Line 22: | Line 22: | ||
local id = getDiscordRichPresenceUserID() | local id = getDiscordRichPresenceUserID() | ||
if id == "" then | if id == "" then | ||
outputChatBox("You didn't allow consent to share data! Grant permission in the settings!") | outputChatBox("You didn't allow consent to share Discord data! Grant permission in the settings!") | ||
else | else | ||
outputChatBox(" | outputChatBox("Your Discord userid: "..id) | ||
end | end | ||
end | end |
Latest revision as of 17:23, 17 December 2023
Important Note: The function will correctly return the UserID if the user has given consent beforehand and is connected to the Rich Presence application. |
Syntax
string getDiscordRichPresenceUserID()
Returns
It will return an empty string ("") if the user has not given consent or has disabled the Rich Presence synchronization option. Otherwise, it will return the userid as a string.
Example
This example displays the user's userid in the chat if they have granted permission to share data. Otherwise, they will receive an appropriate message.
addCommandHandler("getmyuserid", function () if isDiscordRichPresenceConnected() then local id = getDiscordRichPresenceUserID() if id == "" then outputChatBox("You didn't allow consent to share Discord data! Grant permission in the settings!") else outputChatBox("Your Discord userid: "..id) end end end )