SetDiscordRichPresenceButton: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} The function sets a custom button through which we can access the website on Discord. ==Syntax== <syntaxhighlight lang="lua"> bool setDiscordRichPresenceButton(int index, string text, string url) </syntaxhighlight> {{OOP||DiscordRPC:setButton}} ===Required arguments=== *'''index''': a int index of the button (possible 1 and 2) *'''text''': a string with title name *'''url''': a string with url name (works only with '''https://''' or...")
 
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{Important Note|To use this function, you must set up your own application [[setDiscordApplicationID]]}}
{{New feature/item|3.0161|1.6.0|22270|
The function sets a custom button through which we can access the website on Discord.
The function sets a custom button through which we can access the website on Discord.
}}


==Syntax==  
==Syntax==  
Line 10: Line 13:


===Required arguments===
===Required arguments===
*'''index''': a int index of the button (possible 1 and 2)
*'''index''': a int representing the index of the button (possible values: 1 or 2)
*'''text''': a string with title name
*'''text''': a string containing the title of the button
*'''url''': a string with url name (works only with '''https://''' or '''mtasa://''')
*'''url''': a string containing the button URL (only works with '''https://''' or '''mtasa://''')


===Returns===
===Returns===
Returns ''true'' if function succeeds, ''false'' if the client has disabled synchronisation.
Returns ''true'' if function succeeds, ''false'' otherwise.


==Example==
==Example==
This example prints out if the application was successfully set up and set custom buttons.
This example creates two custom buttons in our Discord Rich Presence application.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local app_key = "YOUR_APPLICATION_KEY"
local app_id = "YOUR_APPLICATION_ID"
if setDiscordApplicationID(app_key) then  
if setDiscordApplicationID(app_id) then  
     setDiscordRichPresenceButton(1, "Connect to server", "mtasa://youraddressip")
     setDiscordRichPresenceButton(1, "Connect to server", "mtasa://youraddressip")
     setDiscordRichPresenceButton(2, "MTA Homepage", "https:/mtasa.com")
     setDiscordRichPresenceButton(2, "MTA Homepage", "https://mtasa.com")
end  
end  
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 18:36, 24 October 2023

[[{{{image}}}|link=|]] Important Note: To use this function, you must set up your own application setDiscordApplicationID
ADDED/UPDATED IN VERSION 1.6.0 r22270:

The function sets a custom button through which we can access the website on Discord.

Syntax

bool setDiscordRichPresenceButton(int index, string text, string url)

OOP Syntax Help! I don't understand this!

Method: DiscordRPC:setButton(...)


Required arguments

  • index: a int representing the index of the button (possible values: 1 or 2)
  • text: a string containing the title of the button
  • url: a string containing the button URL (only works with https:// or mtasa://)

Returns

Returns true if function succeeds, false otherwise.

Example

This example creates two custom buttons in our Discord Rich Presence application.

local app_id = "YOUR_APPLICATION_ID"
if setDiscordApplicationID(app_id) then 
    setDiscordRichPresenceButton(1, "Connect to server", "mtasa://youraddressip")
    setDiscordRichPresenceButton(2, "MTA Homepage", "https://mtasa.com")
end 

See Also

ADDED/UPDATED IN VERSION 1.6.0 r22342: