diff --git a/assets/data/discord.hx b/assets/data/discord.hx
index 220efbfa..5aad1856 100644
--- a/assets/data/discord.hx
+++ b/assets/data/discord.hx
@@ -4,6 +4,15 @@ function onGameOver() {
DiscordUtil.changePresence('Game Over', PlayState.SONG.meta.displayName + " (" + PlayState.difficulty + ")");
}
+function onDiscordPresenceUpdate(e) {
+ var data = e.presence;
+
+ if(data.button1Label == null)
+ data.button1Label = "Codename Engine Discord";
+ if(data.button1Url == null)
+ data.button1Url = "https://discord.gg/2NTCdsQvx4";
+}
+
function onPlayStateUpdate() {
DiscordUtil.changeSongPresence(
PlayState.instance.detailsText,
diff --git a/libs.xml b/libs.xml
index 5afacfc3..95f64aee 100644
--- a/libs.xml
+++ b/libs.xml
@@ -11,7 +11,8 @@
-
+
+
diff --git a/source/funkin/backend/utils/DiscordUtil.hx b/source/funkin/backend/utils/DiscordUtil.hx
index e02a6b74..e74df162 100644
--- a/source/funkin/backend/utils/DiscordUtil.hx
+++ b/source/funkin/backend/utils/DiscordUtil.hx
@@ -206,6 +206,13 @@ class DiscordUtil
Utils.safeSetWrapper(dp.joinSecret, data.joinSecret, fixString);
Utils.safeSetWrapper(dp.spectateSecret, data.spectateSecret, fixString);
Utils.safeSet(dp.instance, data.instance);
+ if (data.matchSecret == null && data.joinSecret == null && data.spectateSecret == null)
+ {
+ Utils.safeSetWrapper(dp.button1Label, data.button1Label, fixString);
+ Utils.safeSetWrapper(dp.button1Url, data.button1Url, fixString);
+ Utils.safeSetWrapper(dp.button2Label, data.button2Label, fixString);
+ Utils.safeSetWrapper(dp.button2Url, data.button2Url, fixString);
+ }
Discord.UpdatePresence(cpp.RawConstPointer.addressOf(dp));
#end
@@ -255,8 +262,8 @@ class DiscordUtil
Logs.traceColored([
Logs.logText("[Discord] ", BLUE),
- Logs.logText("Connected to User ("),
- Logs.logText(user.tag, GRAY),
+ Logs.logText("Connected to User " + user.globalName + " ("),
+ Logs.logText(user.handle, GRAY),
Logs.logText(")")
], INFO);
@@ -285,9 +292,7 @@ class DiscordUtil
Logs.traceColored([
Logs.logText("[Discord] ", BLUE),
- Logs.logText("Error ("),
- Logs.logText('$errorCode: $finalMsg', RED),
- Logs.logText(")")
+ Logs.logText('Error ($errorCode: $finalMsg)', RED)
], ERROR);
call("onError", [errorCode, cast(finalMsg, String)]);
@@ -336,7 +341,7 @@ final class DUser
/**
* The username + discriminator if they have it
**/
- public var tag:String;
+ public var handle:String;
/**
* The user id, aka 860561967383445535
@@ -358,6 +363,26 @@ final class DUser
**/
public var avatar:String;
+ /**
+ * The user's display name
+ **/
+ public var globalName:String;
+
+ /**
+ * If the user is a bot or not
+ **/
+ public var bot:Bool;
+
+ /**
+ * Idk check discord docs
+ **/
+ public var flags:Int;
+
+ /**
+ * If the user has nitro
+ **/
+ public var premium:NitroType;
+
private function new()
{
}
@@ -374,11 +399,15 @@ final class DUser
d.username = userData.username;
d.discriminator = Std.parseInt(userData.discriminator);
d.avatar = userData.avatar;
+ d.globalName = userData.globalName;
+ d.bot = userData.bot;
+ d.flags = userData.flags;
+ d.premium = userData.premium;
if (d.discriminator != 0)
- d.tag = '${d.username}#${d.discriminator}';
+ d.handle = '${d.username}#${d.discriminator}';
else
- d.tag = '${d.username}';
+ d.handle = '${d.username}';
return d;
}
@@ -389,6 +418,14 @@ final class DUser
return BitmapData.fromBytes(HttpUtil.requestBytes('https://cdn.discordapp.com/avatars/$userId/$avatar.png?size=$size'));
}
+enum abstract NitroType(Int) to Int from Int
+{
+ var NONE = 0;
+ var NITRO_CLASSIC = 1;
+ var NITRO = 2;
+ var NITRO_BASIC = 3;
+}
+
typedef DPresence =
{
var ?state:String; /* max 128 bytes */
@@ -407,6 +444,10 @@ typedef DPresence =
var ?joinSecret:String; /* max 128 bytes */
var ?spectateSecret:String; /* max 128 bytes */
var ?instance:OneOfTwo;
+ var ?button1Label:String; /* max 32 bytes */
+ var ?button1Url:String; /* max 512 bytes */
+ var ?button2Label:String; /* max 32 bytes */
+ var ?button2Url:String; /* max 512 bytes */
}
typedef DEvents =
diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx
index 21c3c2b7..d7df2ab1 100644
--- a/source/funkin/editors/charter/Charter.hx
+++ b/source/funkin/editors/charter/Charter.hx
@@ -530,7 +530,7 @@ class Charter extends UIState {
notesGroup.autoSort = false;
var noteCount:Int = 0;
for (strL in PlayState.SONG.strumLines)
- for (note in strL.notes) noteCount++;
+ noteCount += strL.notes.length;
notesGroup.preallocate(noteCount);
var notesCreated:Int = 0;