Revert "Develop > main"

This commit is contained in:
Core 2022-02-05 09:34:33 +00:00 committed by GitHub
parent d7d90fbc36
commit f843fe0ba7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 6687 additions and 25151 deletions

View file

@ -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)