Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export function createTemplateValues(presence, { labels = {} } = {}) {
episode: presence.episode == null ? "" : String(presence.episode),
episodeCode: episodeCode(presence.season, presence.episode),
provider: presence.provider ?? "",
mediaType: presence.mediaType ?? "",
// Normalized presence carries the kind; the raw mediaType field is the
// fallback for older callers passing a plain object.
mediaType: presence.kind ?? presence.mediaType ?? "",
state: presence.state ?? "",
stateLabel: stateLabels[presence.state] ?? presence.state ?? "",
position: formatDuration(presence.positionMs),
Expand Down
7 changes: 7 additions & 0 deletions test/discord-activity-name.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ test("statusDisplayType is sent even when there is no name (no artist, or an emp
assert.equal(noArtist.statusDisplayType, "state");
assert.equal(formatDiscordActivity(song(), { name: "", statusDisplayType: "details" }).statusDisplayType, "details");
});

test("the {mediaType} token renders the normalized kind in the Discord name (#1119)", () => {
for (const kind of ["track", "movie", "episode", "show", "unknown"]) {
const presence = createPresence({ state: "playing", kind, title: "T", provider: "plex", updatedAt: "2026-10-02T12:00:00Z" });
assert.equal(formatDiscordActivity(presence, { name: "{mediaType}" }).name, kind);
}
});
6 changes: 6 additions & 0 deletions test/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,9 @@ test("{service} for a provider id that names an Object.prototype property is pla
assert.equal(service, id.charAt(0).toUpperCase() + id.slice(1));
}
});

test("mediaType comes from the normalized presence kind, raw field as fallback (#1119)", () => {
assert.equal(createTemplateValues({ kind: "track", state: "playing" }).mediaType, "track");
assert.equal(createTemplateValues({ kind: "movie", state: "playing" }).mediaType, "movie");
assert.equal(createTemplateValues({ mediaType: "episode", state: "paused" }).mediaType, "episode");
});
Loading