https://wiki.mudlet.org/index.php?title=Manual:Discord_Functions/pl&feed=atom&action=historyManual:Discord Functions/pl - Revision history2024-03-29T11:02:45ZRevision history for this page on the wikiMediaWiki 1.35.0https://wiki.mudlet.org/index.php?title=Manual:Discord_Functions/pl&diff=10969&oldid=prevWikiSysop: Updating translation from gettext import2020-07-03T06:09:35Z<p>Updating translation from gettext import</p>
<p><b>New page</b></p><div><languages/><br />
{{TOC right}}<br />
For an overview on how all of these functions tie in together, see our [[Special:MyLanguage/Manual:Scripting#Discord_Rich_Presence|Discord scripting overview]].<br />
<br />
<br />
<span id="getdiscorddetail"></span><br />
==getDiscordDetail==<br />
<br />
;getDiscordDetail()<br />
: Returns the text used for the Discord Rich Presence detail field. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the detail is shown.<br />
<br />
See also: <br />
[[#setdiscorddetail|setDiscordDetail]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
print("Discord detail is: ".. getDiscordDetail())<br />
</syntaxhighlight><br />
<br />
<br />
<span id="getdiscordlargeicon"></span><br />
==getDiscordLargeIcon==<br />
<br />
;getDiscordLargeIcon()<br />
: Returns the large icon name used for the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the large icon is shown.<br />
<br />
See also: <br />
[[#setdiscordlargeicon|setDiscordLargeIcon]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
print("Discord large icon is: ".. getDiscordLargeIcon())<br />
</syntaxhighlight><br />
<br />
<br />
<span id="getdiscordlargeicontext"></span><br />
==getDiscordLargeIconText==<br />
<br />
;getDiscordLargeIconText()<br />
: Returns the text used as a tooltip for the large icon in the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the large icon is shown.<br />
<br />
See also: <br />
[[#setdiscordlargeicontext|setDiscordLargeIconText]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
print("Discord large icon tooltip is: ".. setDiscordLargeIconText())<br />
</syntaxhighlight><br />
<br />
<br />
<span id="getdiscordparty"></span><br />
==getDiscordParty==<br />
<br />
;getDiscordParty()<br />
: Returns the current and max party values used in the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the the party info is shown.<br />
<br />
See also: <br />
[[#setdiscordparty|setDiscordParty]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local currentsize, maxsize = getDiscordParty()<br />
print(string.format("Discord party: %d out of %d", currentsize, maxsize))<br />
</syntaxhighlight><br />
<br />
<br />
<br />
<span id="getdiscordsmallicon"></span><br />
==getDiscordSmallIcon==<br />
<br />
;getDiscordSmallIcon()<br />
: Returns the small icon name used for the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the small icon is shown.<br />
<br />
See also: <br />
[[#setdiscordsmallicon|setDiscordSmallIcon]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
print("Discord small icon is: ".. getDiscordSmallIcon())<br />
</syntaxhighlight><br />
<br />
<br />
==getDiscordSmallIconText==<br />
<br />
;getDiscordSmallIconText()<br />
: Returns the text used as a tooltip for the small icon in the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the small icon is shown.<br />
<br />
See also: <br />
[[#setdiscordsmallicontext|setDiscordSmallIconText]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
print("Discord small icon tooltip is: ".. setDiscordSmallIconText())<br />
</syntaxhighlight><br />
<br />
<br />
<span id="getdiscordstate"></span><br />
==getDiscordState==<br />
<br />
;getDiscordState()<br />
: Returns the text used for the Discord Rich Presence state field. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the state is shown.<br />
<br />
See also: <br />
[[#setdiscordstate|setDiscordState]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
print("Discord state is: ".. getDiscordState())<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordapplicationid"></span><br />
==setDiscordApplicationID==<br />
<br />
;setDiscordApplicationID(id)<br />
: Set a custom Discord ID so Discord Rich Presence will show "Playing <your game>" instead of "Playing Mudlet". This function is intended for game authors. Note that you can also set it [[Standards:Discord GMCP|automatically over GMCP]], no pre-installation of scripts required. The Discord privacy option "Enable Lua API" must be enabled for this to work. Returns true if the Discord application ID is in the correct format.<br />
<br />
If you're a game author, you can register your game [https://discordapp.com/developers/applications/ over at Discord] to obtain the "client ID" to be used for this function. Once you do so, make sure to upload the games icon as an art asset under the name of <code>server-icon</code>.<br />
<br />
Mudlet calls the client ID an application ID to avoid confusion with the Mudlet internal Discord client ID.<br />
<br />
;Parameters <br />
* ''id:'' (required) id as a string.<br />
<br />
[[File:Mudlet Discord ApplicationID.png|thumb|right]]<br />
<br />
See also: <br />
[[#setdiscordgame|setDiscordGame]], [[#usingmudletsdiscordid|usingMudletsDiscordID]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- set the ID to Mudlets own as an example<br />
setDiscordApplicationID("450571881909583884")<br />
</syntaxhighlight><br />
<br />
{{note}} So you do not have to remember that long number you can also reset to the default Mudlet ID by calling this function without an argument:<br />
<syntaxhighlight lang="lua"><br />
setDiscordApplicationID()<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscorddetail"></span><br />
==setDiscordDetail==<br />
<br />
;setDiscordDetail()<br />
: Sets the text to be shown in the detail field of Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the detail is shown. Note that this will overwrite the same information set by [[#setdiscordgame|setDiscordGame()]].<br />
<br />
See also: <br />
[[#getdiscorddetail|getDiscordDetail]], [[#setdiscordgame|setDiscordGame]]<br />
<br />
{{note}} To ensure privacy, the detail will only be shown if the Lua API is enabled and the detail is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- set detail to your character name in-game, as an example<br />
setDiscordDetail("Vadi")<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordelapsedstarttime"></span><br />
==setDiscordElapsedStartTime==<br />
<br />
;setDiscordElapsedStartTime(time)<br />
: Sets the time to be shown for "## elapsed" field in Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the elapsed time is shown.<br />
<br />
;Parameters <br />
* ''time:'' (required) time as a [https://en.wikipedia.org/wiki/Unix_time Unix time]. To get the current Unix time in Lua, use <code>os.time(os.date("*t"))</code>.<br />
<br />
See also: <br />
[[#setdiscordremainingendtime|setDiscordRemainingEndTime]]<br />
<br />
{{note}} To ensure privacy, the time will only be shown if the Lua API is enabled and the time is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- set the timer to start counting up from now:<br />
setDiscordElapsedStartTime(os.time(os.date("*t")))<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordgame"></span><br />
==setDiscordGame==<br />
<br />
;setDiscordGame()<br />
: Sets the given game to be shown in the "detail" field and the game's icon as the large icon in Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the detail and large icon is shown. This is an alternative way of showing which game you're playing - a better way, if you're the game author, is to use [[Standards:Discord GMCP|GMCP]] (no pre-installation of scripts required) or [[#setdiscordapplicationid|setDiscordApplicationID()]].<br />
<br />
Currently supported games are: Achaea, Aetolia, Imperian, Luminari, Lusternia, MidMUD, Starmourn, WoTMUD. To add a new game to the list, [https://www.mudlet.org/contact/ get in touch].<br />
<br />
See also: <br />
[[#setdiscordapplicationid|setDiscordApplicationID]]<br />
<br />
{{note}} To ensure privacy, the game and icon will only be shown if the Lua API is enabled, and detail and large icon are set to show.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
setDiscordGame("WoTMUD")<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordlargeicon"></span><br />
==setDiscordLargeIcon==<br />
<br />
;setDiscordLargeIcon()<br />
: Sets the large icon to be shown in Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference the icon is shown.<br />
<br />
Icons supported by default in Mudlet: armor, axe, backpack, bow, coin, dagger, envelope, gem-blue, gem-green, gem-red, hammer, heart, helmet, map, shield, tome, tools, wand, wood-sword ([https://opengameart.org/content/fantasy-icon-pack-by-ravenmore-0 icons credit]). To add a new icon to the list, [https://www.mudlet.org/contact/ get in touch] (the Discord limit is 150 icons).<br />
<br />
If you're a game author, you can register your own game with Discord and upload your own icons instead of using the ones registered by Mudlet, see [[#setdiscordapplicationid|setDiscordApplicationID()]].<br />
<br />
See also: <br />
[[#getdiscordlargeicon|getDiscordLargeIcon]], [[#setdiscordlargeicontext|setDiscordLargeIconText]], [[#setdiscordapplicationid|setDiscordApplicationID]]<br />
<br />
{{note}} To ensure privacy, the icon will only be shown if the Lua API is enabled and the large icon is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
setDiscordLargeIcon("coin")<br />
setDiscordLargeIconText("Fishing")<br />
setDiscordState("Fishing")<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordlargeicontext"></span><br />
==setDiscordLargeIconText==<br />
<br />
;setDiscordLargeIconText()<br />
: Sets the tooltip for the large icon in the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference the large icon is shown.<br />
<br />
See also: <br />
[[#setdiscordlargeicon|setDiscordLargeIcon]]<br />
<br />
{{note}} To ensure privacy, the tooltip will only be shown if the Lua API is enabled, and large icon with the large icon tooltip is set to show.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
setDiscordLargeIcon("axe")<br />
setDiscordLargeIconText("Killing heterics")<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordparty"></span><br />
==setDiscordParty==<br />
<br />
;setDiscordParty(current, max)<br />
: Sets the party information the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference the party is shown.<br />
<br />
;Parameters <br />
* ''current:'' (required) current party amount.<br />
* ''max:'' (optional) max party amount - if not provided, then the max is set to the current amount.<br />
<br />
See also: <br />
[[#getdiscordparty|getDiscordParty]]<br />
<br />
{{note}} To ensure privacy, the party will only be shown if the Lua API is enabled and the party information is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- show that 5 out of 10 people are in currently in the party<br />
setDiscordParty(5, 10)<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordremainingendtime"></span><br />
==setDiscordRemainingEndTime==<br />
<br />
;setDiscordRemainingEndTime(time)<br />
: Sets the time to be shown for "## remaining" field in Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the remaining time is shown.<br />
<br />
;Parameters <br />
* ''time:'' (required) time as a [https://en.wikipedia.org/wiki/Unix_time Unix time]. To get the current Unix time in Lua, use <code>os.time(os.date("*t"))</code>.<br />
<br />
See also: <br />
[[#setdiscordelapsedstarttime|setDiscordElapsedStartTime]]<br />
<br />
{{note}} To ensure privacy, the time will only be shown if the Lua API is enabled and the time is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- set the timer to start counting down from an hour from now<br />
setDiscordRemainingEndTime(os.time(os.date("*t"))+(60 * 60))<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordsmallicon"></span><br />
==setDiscordSmallIcon==<br />
<br />
;setDiscordSmallIcon()<br />
: Sets the small icon to be shown in Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference the icon is shown.<br />
<br />
Icons supported by default in Mudlet: armor, axe, backpack, bow, coin, dagger, envelope, gem-blue, gem-green, gem-red, hammer, heart, helmet, map, shield, tome, tools, wand, wood-sword ([https://opengameart.org/content/fantasy-icon-pack-by-ravenmore-0 icons credit]). To add a new icon to the list, [https://www.mudlet.org/contact/ get in touch] (the Discord limit is 150 icons).<br />
<br />
If you're a game author, you can register your own game with Discord and upload your own icons instead of using the ones registered by Mudlet, see [[#setdiscordapplicationid|setDiscordApplicationID()]].<br />
<br />
See also: <br />
[[#getdiscordsmallicon|getDiscordSmallIcon]], [[#setdiscordsmallicontext|setDiscordSmallIconText]], [[#setdiscordapplicationid|setDiscordApplicationID]]<br />
<br />
{{note}} To ensure privacy, the icon will only be shown if the Lua API is enabled and the small icon is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
setDiscordSmallIcon("envelope")<br />
setDiscordSmallIconText("Writing letters")<br />
setDiscordState("Writing letters")<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordsmallicontext"></span><br />
==setDiscordSmallIconText==<br />
<br />
;setDiscordSmallIconText()<br />
: Sets the tooltip for the small icon in the Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference the small icon is shown.<br />
<br />
See also: <br />
[[#setdiscordsmallicon|setDiscordSmallIcon]]<br />
<br />
{{note}} To ensure privacy, the tooltip will only be shown if the Lua API is enabled, and small icon with the small icon tooltip is set to show.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
setDiscordSmallIcon("map")<br />
setDiscordSmallIconText("Exploring")<br />
</syntaxhighlight><br />
<br />
<br />
<span id="setdiscordstate"></span><br />
==setDiscordState==<br />
<br />
;setDiscordState(state)<br />
: Sets the text to be shown in the state field of Discord Rich Presence. See [https://discordapp.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields Discord docs] for a handy image reference on where the state is shown.<br />
<br />
See also: <br />
[[#getdiscordstate|getDiscordState]], [[#setdiscorddetail|setDiscordDetail]]<br />
<br />
{{note}} To ensure privacy, the state will only be shown if the Lua API is enabled and the state is not hidden.<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- set state to your current area<br />
local currentarea = getRoomArea(getPlayerRoom())<br />
local areaname = getAreaTableSwap()[currentarea]<br />
setDiscordDetail(areaname)<br />
</syntaxhighlight><br />
<br />
<br />
<span id="usingmudletsdiscordid"></span><br />
==usingMudletsDiscordID==<br />
<br />
;usingMudletsDiscordID()<br />
: Returns true if the currently playing game is set to "Mudlet". You can change this with [[#setdiscordapplicationid|setDiscordApplicationID()]].<br />
<br />
See also: <br />
[[#setdiscordapplicationid|setDiscordApplicationID]]<br />
<br />
{{note}} Available since Mudlet 3.14.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
if usingMudletsDiscordID() then<br />
print('It is showing "Playing Mudlet" right now!')<br />
end<br />
</syntaxhighlight></div>WikiSysop