fix(RichPresence) IPC Convert
This commit is contained in:
parent
3d792564a3
commit
46800d957b
@ -8,12 +8,7 @@ const getUUID = () =>
|
|||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a => (a ^ ((Math.random() * 16) >> (a / 4))).toString(16));
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a => (a ^ ((Math.random() * 16) >> (a / 4))).toString(16));
|
||||||
// Function check url valid (ok copilot)
|
// Function check url valid (ok copilot)
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const checkUrl = (url, ipc = false) => {
|
const checkUrl = url=> /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(url);
|
||||||
// eslint-disable-next-line no-useless-escape
|
|
||||||
const res = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(url);
|
|
||||||
if (!res && !ipc) return false;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CustomStatus {
|
class CustomStatus {
|
||||||
/**
|
/**
|
||||||
@ -175,7 +170,7 @@ class RichPresence {
|
|||||||
if (!(this.assets instanceof Object)) this.assets = {};
|
if (!(this.assets instanceof Object)) this.assets = {};
|
||||||
if (typeof image != 'string') {
|
if (typeof image != 'string') {
|
||||||
image = null;
|
image = null;
|
||||||
} else if (checkUrl(image, this.ipc)) {
|
} else if (checkUrl(image)) {
|
||||||
// Discord URL:
|
// Discord URL:
|
||||||
image = image
|
image = image
|
||||||
.replace('https://cdn.discordapp.com/', 'mp:')
|
.replace('https://cdn.discordapp.com/', 'mp:')
|
||||||
@ -183,7 +178,7 @@ class RichPresence {
|
|||||||
.replace('https://media.discordapp.net/', 'mp:')
|
.replace('https://media.discordapp.net/', 'mp:')
|
||||||
.replace('http://media.discordapp.net/', 'mp:');
|
.replace('http://media.discordapp.net/', 'mp:');
|
||||||
//
|
//
|
||||||
if (!image.startsWith('mp:')) {
|
if (!image.startsWith('mp:') && !this.ipc) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'INVALID_URL',
|
'INVALID_URL',
|
||||||
`
|
`
|
||||||
@ -212,7 +207,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
|
|||||||
if (!(this.assets instanceof Object)) this.assets = {};
|
if (!(this.assets instanceof Object)) this.assets = {};
|
||||||
if (typeof image != 'string') {
|
if (typeof image != 'string') {
|
||||||
image = null;
|
image = null;
|
||||||
} else if (checkUrl(image, this.ipc)) {
|
} else if (checkUrl(image)) {
|
||||||
// Discord URL:
|
// Discord URL:
|
||||||
image = image
|
image = image
|
||||||
.replace('https://cdn.discordapp.com/', 'mp:')
|
.replace('https://cdn.discordapp.com/', 'mp:')
|
||||||
@ -220,7 +215,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
|
|||||||
.replace('https://media.discordapp.net/', 'mp:')
|
.replace('https://media.discordapp.net/', 'mp:')
|
||||||
.replace('http://media.discordapp.net/', 'mp:');
|
.replace('http://media.discordapp.net/', 'mp:');
|
||||||
//
|
//
|
||||||
if (!image.startsWith('mp:')) {
|
if (!image.startsWith('mp:') && !this.ipc) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'INVALID_URL',
|
'INVALID_URL',
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user