GetDiscordRichPresenceUserID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{Important Note|The function will correctly display the UserID when the user has given consent and successfully connected to the Rich Presence application.}} {{New feature/item|3.0161|1.6.0|22329| The function returns the client Discord UserID. }} ==Syntax== <syntaxhighlight lang="lua"> string getDiscordRichPresenceUserID() </syntaxhighlight> ===Returns=== It will return an ''empty string ("")'' if the user has not given consent or has...")
 
m (fix nightly version that introduced this to 22342)
Line 2: Line 2:
{{Client function}}
{{Client function}}
{{Important Note|The function will correctly display the UserID when the user has given consent and successfully connected to the Rich Presence application.}}
{{Important Note|The function will correctly display the UserID when the user has given consent and successfully connected to the Rich Presence application.}}
{{New feature/item|3.0161|1.6.0|22329|
{{New feature/item|3.0161|1.6.0|22342|
The function returns the client Discord UserID.
The function returns the client Discord UserID.
}}
}}

Revision as of 17:10, 17 December 2023

[[{{{image}}}|link=|]] Important Note: The function will correctly display the UserID when the user has given consent and successfully connected to the Rich Presence application.
ADDED/UPDATED IN VERSION 1.6.0 r22342:

The function returns the client Discord UserID.

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 when 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 data! Grant permission in the settings!")
            else 
                outputChatBox("Yours userid: "..id)
            end 
        end 
    end
)

See Also

ADDED/UPDATED IN VERSION 1.6.0 r22342: