Skip to content

Commit b984d0b

Browse files
committed
Implemented Discord Presence
1 parent 7507549 commit b984d0b

File tree

15 files changed

+238
-207
lines changed

15 files changed

+238
-207
lines changed

Minecraft Note Block Studio.yyp

Lines changed: 14 additions & 203 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
60.5 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define np_get_avatar_url
2+
3+
if (!is_string(argument0) || !is_string(argument1) || !string_length(argument0) || !string_length(argument1)) return "";
4+
return "https://cdn.discordapp.com/avatars/" + argument0 + "/" + argument1 + ".png";

extensions/NekoPresence/NekoPresence.yy

Lines changed: 147 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
72.5 KB
Binary file not shown.
680 KB
Binary file not shown.

objects/obj_controller/Step_0.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
script_execute(control_step,0,0,0,0,0);
1+
script_execute(control_step,0,0,0,0,0);

objects/obj_presence/Create_0.gml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#macro DISCORD_APP_ID "848873736702132246"
2+
3+
ready = false;
4+
if (!np_initdiscord(DISCORD_APP_ID, true, 0))
5+
{
6+
show_error("NekoPresence init fail.", true);
7+
}

objects/obj_presence/Other_60.gml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (async_load[? "status"] >= 0) {
2+
sprite_index = async_load[? "id"];
3+
}

objects/obj_presence/Other_70.gml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var o = obj_controller;
2+
3+
var ev_type = async_load[? "event_type"];
4+
5+
if (ev_type == "DiscordReady" || ready = true)
6+
{
7+
window_set_caption("We're ready!");
8+
ready = true;
9+
show_debug_message("date: " + string(date_current_datetime()));
10+
np_setpresence_timestamps(date_current_datetime(), 0, false);
11+
np_setpresence_more("Minecraft Note Block Studio", "", false);
12+
13+
//np_setpresence() should ALWAYS come the last!!
14+
np_setpresence(condstr(o.filename = "", "Unsaved song") + filename_name(o.filename), time_str(o.marker_pos / o.tempo) + " / " + time_str(o.enda / o.tempo), "note", "");
15+
16+
// passing a URL will add this sprite asynchronously via *internets*
17+
sprite_add(np_get_avatar_url(async_load[? "user_id"], async_load[? "avatar"]), 1, false, false, 0, 0);
18+
} else {
19+
show_error("NekoPresence error:\n" + json_encode(async_load), true)
20+
}
21+
show_debug_message("1")

0 commit comments

Comments
 (0)