Revert "Develop > main"
This commit is contained in:
parent
d7d90fbc36
commit
f843fe0ba7
86 changed files with 6687 additions and 25151 deletions
|
@ -90,44 +90,6 @@ export default class DiscordRichPresence {
|
|||
}).catch((e: any) => console.error(`[DiscordRPC][disconnect] ${e}`));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the Discord activity object
|
||||
*/
|
||||
private filterActivity(activity: any, attributes: any): Object {
|
||||
|
||||
// Checks if the name is greater than 128 because some songs can be that long
|
||||
if (activity.details && activity.details.length > 128) {
|
||||
activity.details = activity.details.substring(0, 125) + '...'
|
||||
}
|
||||
|
||||
// Check large image
|
||||
if (activity.largeImageKey === null || activity.largeImageKey === ""){
|
||||
activity.largeImageKey = "cider";
|
||||
}
|
||||
|
||||
// Timestamp
|
||||
if (new Date(attributes.endTime).getTime() < 0) {
|
||||
delete activity.startTime
|
||||
delete activity.endTime
|
||||
}
|
||||
|
||||
// not sure
|
||||
if (!attributes.artistName) {
|
||||
delete activity.state;
|
||||
}
|
||||
|
||||
if (!activity.largeImageText || activity.largeImageText.length < 2) {
|
||||
delete activity.largeImageText
|
||||
}
|
||||
|
||||
activity.buttons.forEach((key: {label: string, url: string}, _v: Number) => {
|
||||
if (key.url.includes('undefined') || key.url.includes('no-id-found')) {
|
||||
activity.buttons.splice(key, 1);
|
||||
}
|
||||
})
|
||||
return activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the activity of the client
|
||||
* @param {object} attributes
|
||||
|
@ -143,18 +105,23 @@ export default class DiscordRichPresence {
|
|||
this._activity = {
|
||||
details: attributes.name,
|
||||
state: `${attributes.artistName ? `by ${attributes.artistName}` : ''}`,
|
||||
startTimestamp: attributes.startTime,
|
||||
endTimestamp: attributes.endTime,
|
||||
largeImageKey: attributes.artwork.url.replace('{w}', '1024').replace('{h}', '1024'),
|
||||
startTimestamp: ((new Date(attributes.endTime).getTime() < 0) ? null : attributes.startTime),
|
||||
endTimestamp: ((new Date(attributes.endTime).getTime() < 0) ? null : attributes.endTime),
|
||||
largeImageKey: (attributes.artwork.url.replace('{w}', '1024').replace('{h}', '1024')) ?? 'cider',
|
||||
largeImageText: attributes.albumName,
|
||||
instance: false, // Whether the activity is in a game session
|
||||
|
||||
buttons: [
|
||||
{label: "Listen on Cider", url: attributes.url.cider},
|
||||
{label: "View on Apple Music", url: attributes.url.appleMusic},
|
||||
]
|
||||
};
|
||||
|
||||
this._activity = this.filterActivity(this._activity, attributes)
|
||||
|
||||
// Checks if the name is greater than 128 because some songs can be that long
|
||||
if (this._activity.details && this._activity.details.length > 128) {
|
||||
this._activity.details = this._activity.details.substring(0, 125) + '...'
|
||||
}
|
||||
|
||||
// Check if its pausing (false) or playing (true)
|
||||
if (!attributes.status) {
|
||||
|
@ -212,7 +179,7 @@ export default class DiscordRichPresence {
|
|||
|
||||
/**
|
||||
* Runs on playback State Change
|
||||
* @param attributes Music Attributes (attributes.status = current state)
|
||||
* @param attributes Music Attributes (attributes.state = current state)
|
||||
*/
|
||||
onPlaybackStateDidChange(attributes: object): void {
|
||||
this.updateActivity(attributes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue