Skip to content

Commit 6d41983

Browse files
committed
Discord functions
1 parent f58e79b commit 6d41983

28 files changed

+216
-158
lines changed

elements/Discord/discordrpc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: discordrpc
2+
description: The **discordrpc** class represents a static class providing functions for Discord Rich Presence.
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
addCommandHandler("getmyuserid",
2-
function ()
3-
if isDiscordRichPresenceConnected() then
4-
local id = getDiscordRichPresenceUserID()
5-
if id == "" then
6-
outputChatBox("You didn't allow consent to share Discord data! Grant permission in the settings!")
7-
else
8-
outputChatBox("Your Discord userid: "..id)
9-
end
10-
end
1+
addCommandHandler("getmyuserid", function()
2+
if isDiscordRichPresenceConnected() then
3+
local id = getDiscordRichPresenceUserID()
4+
if id == "" then
5+
outputChatBox("You didn't allow consent to share Discord data! Grant permission in the settings!")
6+
else
7+
outputChatBox("Your Discord userid: " .. id)
8+
end
119
end
12-
)
10+
end)
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
addCommandHandler("checkdiscord",
2-
function ()
3-
if isDiscordRichPresenceConnected() then
4-
outputChatBox("You are using Discord Rich Presence, that's cool!")
5-
end
1+
addCommandHandler("checkdiscord", function()
2+
if isDiscordRichPresenceConnected() then
3+
outputChatBox("You are using Discord Rich Presence, that's cool!")
64
end
7-
)
5+
end)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
addCommandHandler("checkdiscord", function()
2+
if DiscordRPC.isConnected() then
3+
outputChatBox("You are using Discord Rich Presence, that's cool!")
4+
end
5+
end)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local app_id = "YOUR_APPLICATION_ID"
2+
if DiscordRPC.setApplication(app_id) then
3+
DiscordRPC.setAsset("asset_name_from_application")
4+
outputChatBox("Yay, we're now using our own application!")
5+
end
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
addCommandHandler("setlogo",
2-
function ()
3-
if isDiscordRichPresenceConnected() then
4-
setDiscordRichPresenceAsset("my_logo", "This is my logo!")
5-
end
1+
addCommandHandler("setlogo", function()
2+
if isDiscordRichPresenceConnected() then
3+
setDiscordRichPresenceAsset("my_logo", "This is my logo!")
64
end
7-
)
5+
end)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
addCommandHandler("setlogo", function()
2+
if DiscordRPC.isConnected() then
3+
DiscordRPC.setAsset("my_logo", "This is my logo!")
4+
end
5+
end)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local app_id = "YOUR_APPLICATION_ID"
2+
if DiscordRPC.setApplication(app_id) then
3+
DiscordRPC.setButton(1, "Connect to server", "mtasa://youraddressip")
4+
DiscordRPC.setButton(2, "MTA Homepage", "https://mtasa.com")
5+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
local app_id = "YOUR_APPLICATION_ID"
2+
if DiscordRPC.setApplication(app_id) then
3+
local name = localPlayer.name
4+
DiscordRPC.setState("In-game")
5+
DiscordRPC.setDetails("currently as "..name)
6+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
local app_id = "YOUR_APPLICATION_ID"
2+
if DiscordRPC.setApplication(app_id) then
3+
DiscordRPC.setState("In-game")
4+
DiscordRPC.setStartTime(1)
5+
DiscordRPC.setEndTime(60) -- 1 minute Remaining
6+
end

0 commit comments

Comments
 (0)