Skip to content

Commit 5e98def

Browse files
committed
add activities to starscript
1 parent d3410f0 commit 5e98def

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Bot/Systems/Starscript/StarscriptHelper.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ guild is SocketGuild sGuild
7676
? sGuild.Owner
7777
: await guild.GetOwnerAsync()));
7878

79+
private static string Fmt(IReadOnlyCollection<IActivity> activities)
80+
{
81+
if (activities.Count is 0)
82+
return "Nothing";
83+
84+
var sb = new StringBuilder();
85+
86+
87+
foreach (var activity in activities)
88+
{
89+
sb.AppendLine(activity switch
90+
{
91+
//we are ignoring custom emojis because there is no guarantee that volte is in the guild where the emoji is from; which could lead to a massive (and ugly) embed field value
92+
CustomStatusGame { Emote: Emoji } csg => $"{csg.Emote} {csg.State}",
93+
CustomStatusGame csg => $"{csg.State}",
94+
SpotifyGame sg => $"Listening to {Format.Url(sg.TrackTitle, sg.TrackUrl)} on Spotify",
95+
_ => activity.Name
96+
});
97+
}
98+
99+
return sb.ToString();
100+
}
79101

80102
public static ValueMap Wrap(IUser user)
81103
{
@@ -91,7 +113,7 @@ public static ValueMap Wrap(IUser user)
91113
uMap.Set("avatarUrl", user.GetDisplayAvatarUrl(size: 256));
92114
uMap.Set("hasPrimaryGuild", user.PrimaryGuild.HasValue);
93115
uMap.TryAddNullable("primaryGuild", user.PrimaryGuild, Wrap);
94-
116+
uMap.Set("statusString", () => Fmt(user.Activities));
95117
uMap.Set("id", user.Id.ToString());
96118
return uMap;
97119
}

0 commit comments

Comments
 (0)