mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Remove activity name option, remove newer Discord clients that may not have full title name set properly
This commit is contained in:
parent
73feb930ac
commit
ec202d1ff8
|
|
@ -70,7 +70,7 @@ export interface DiscordRpcClient {
|
|||
|
||||
declare module 'discord-rpc' {
|
||||
interface Presence {
|
||||
name?: string;
|
||||
type?: DiscordApiActivityType;
|
||||
statusDisplayType?: DiscordApiActivityStatusDisplayType;
|
||||
stateUrl?: string;
|
||||
detailsUrl?: string;
|
||||
|
|
@ -100,8 +100,7 @@ export class DiscordRpcClient extends DiscordRPC.Client {
|
|||
|
||||
setActivity(args: DiscordRPC.Presence, pid = process.pid) {
|
||||
const activity: DiscordRpcActivity = {
|
||||
name: args.name,
|
||||
type: DiscordApiActivityType.PLAYING,
|
||||
type: args.type,
|
||||
status_display_type: args.statusDisplayType,
|
||||
state: args.state,
|
||||
state_url: args.stateUrl,
|
||||
|
|
@ -165,7 +164,8 @@ export class DiscordRpcClient extends DiscordRPC.Client {
|
|||
}
|
||||
}
|
||||
|
||||
type DiscordRpcActivity = Partial<Omit<DiscordApiActivity, 'created_at' | 'application_id' | 'emoji'>>;
|
||||
// RPC clients can't set activity name, but some third-party clients do allow this
|
||||
type DiscordRpcActivity = Partial<Omit<DiscordApiActivity, 'name' | 'created_at' | 'application_id' | 'emoji'>>;
|
||||
|
||||
interface DiscordApiActivity {
|
||||
name: string;
|
||||
|
|
@ -187,7 +187,7 @@ interface DiscordApiActivity {
|
|||
flags?: number;
|
||||
buttons?: DiscordApiActivityButton[];
|
||||
}
|
||||
enum DiscordApiActivityType {
|
||||
export enum DiscordApiActivityType {
|
||||
PLAYING = 0,
|
||||
STREAMING = 1,
|
||||
LISTENING = 2,
|
||||
|
|
@ -226,7 +226,7 @@ interface DiscordApiActivitySecrets {
|
|||
spectate?: string;
|
||||
match?: string;
|
||||
}
|
||||
enum DiscordApiActivityFlags {
|
||||
export enum DiscordApiActivityFlags {
|
||||
INSTANCE = 1 << 0,
|
||||
JOIN = 1 << 1,
|
||||
SPECTATE = 1 << 2,
|
||||
|
|
|
|||
|
|
@ -1236,117 +1236,4 @@ export const titles: Title[] = [
|
|||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Bayonetta Origins: Cereza and the Lost Demon
|
||||
id: '0100cf5010fec000',
|
||||
client: '1107032391496761375',
|
||||
titleName: 'Bayonetta Origins: Cereza and the Lost Demon',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
{
|
||||
// Bayonetta Origins: Cereza and the Lost Demon Demo
|
||||
id: '010002801a3fa000',
|
||||
client: '1107032391496761375',
|
||||
largeImageText: 'Bayonetta Origins: Cereza and the Lost Demon Demo',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// The Legend of Zelda: Tears of the Kingdom
|
||||
id: '0100f2c0115b6000',
|
||||
client: '1107033191912579183',
|
||||
largeImageText: 'The Legend of Zelda: Tears of the Kingdom',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Pikmin 4
|
||||
id: '0100b7c00933a000',
|
||||
client: '1107033455755264010',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
{
|
||||
// Pikmin 4 Demo
|
||||
id: '0100e0b019974000',
|
||||
client: '1107033455755264010',
|
||||
largeImageText: 'Demo',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Metroid Prime Remastered
|
||||
id: '010012101468c000',
|
||||
client: '1107120929953284150',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Pikmin 1
|
||||
id: '0100aa80194b0000',
|
||||
client: '1121121911229927476',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
{
|
||||
// Pikmin 2
|
||||
id: '0100d680194b2000',
|
||||
client: '1121122602782576640',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Everybody 1-2-Switch!
|
||||
id: '01006f900bf8e000',
|
||||
client: '1121122719019323413',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Super Mario Bros. Wonder
|
||||
id: '010015100b514000',
|
||||
client: '1121122895519813642',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// WarioWare: Move It!
|
||||
id: '010045b018ec2000',
|
||||
client: '1121123023961985054',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Super Mario RPG
|
||||
id: '0100bc0018138000',
|
||||
client: '1121123106942095522',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// Detective Pikachu Returns
|
||||
id: '010007500f27c000',
|
||||
client: '1121123195882307604',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
|
||||
{
|
||||
// F-ZERO 99
|
||||
id: '0100ccf019c8c000',
|
||||
client: '1167145130294255637',
|
||||
showPlayingOnline: true,
|
||||
showActiveEvent: true,
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -43,12 +43,6 @@ export interface Title<M extends ExternalMonitor = ExternalMonitor> {
|
|||
*/
|
||||
client?: string;
|
||||
|
||||
/**
|
||||
* Activity name. This overrides the application's name that will appear under the user's name after "Playing ".
|
||||
*/
|
||||
setActivityName?: boolean;
|
||||
activityName?: string;
|
||||
|
||||
/**
|
||||
* Title name to show in Discord. This is *not* the name that will appear under the user's name after "Playing ".
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import createDebug from '../util/debug.js';
|
|||
import { product, version } from '../util/product.js';
|
||||
import { getTitleIdFromEcUrl, hrduration } from '../util/misc.js';
|
||||
import { DiscordPresence, DiscordPresenceContext, DiscordPresencePlayTime } from './types.js';
|
||||
import { DiscordApiActivityStatusDisplayType } from './rpc.js';
|
||||
import { DiscordApiActivityStatusDisplayType, DiscordApiActivityType } from './rpc.js';
|
||||
|
||||
const debug = createDebug('nxapi:discord');
|
||||
|
||||
|
|
@ -45,9 +45,7 @@ export function getDiscordPresence(
|
|||
|
||||
const activity = new DiscordActivity();
|
||||
|
||||
if (title.setActivityName) {
|
||||
activity.name = title.activityName ?? game.name;
|
||||
} else if (title.titleName) {
|
||||
if (title.titleName) {
|
||||
// If this is set it/the title name is used as the details field
|
||||
activity.statusDisplayType = DiscordApiActivityStatusDisplayType.DETAILS;
|
||||
}
|
||||
|
|
@ -97,8 +95,8 @@ export function getDiscordPresence(
|
|||
}
|
||||
|
||||
export class DiscordActivity implements DiscordRPC.Presence {
|
||||
name?: string = undefined;
|
||||
statusDisplayType?: DiscordApiActivityStatusDisplayType | undefined;
|
||||
type?: DiscordApiActivityType = undefined;
|
||||
statusDisplayType?: DiscordApiActivityStatusDisplayType = undefined;
|
||||
details?: string = undefined;
|
||||
state?: string = undefined;
|
||||
largeImageKey?: string = undefined;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user