refactor(RichPresence): getUUID, getExternal => static

Co-Authored-By: Nguyễn Hồng Đức <hongducyb123@gmail.com>
This commit is contained in:
March 7th 2022-08-29 10:29:03 +07:00
parent 8a9d7e8713
commit da93f6364d
3 changed files with 8 additions and 8 deletions

View File

@ -94,7 +94,7 @@ const r = new Discord.RichPresence()
.setParty({ .setParty({
max: 9, max: 9,
current: 1, current: 1,
id: Discord.getUUID(), id: Discord.RichPresence.getUUID(),
}) })
.setStartTimestamp(Date.now()) .setStartTimestamp(Date.now())
.setAssetsLargeImage('mp:attachments/820557032016969751/991172011483218010/unknown.png') .setAssetsLargeImage('mp:attachments/820557032016969751/991172011483218010/unknown.png')
@ -118,7 +118,7 @@ const r = new Discord.RichPresence()
.setParty({ .setParty({
max: 9, max: 9,
current: 1, current: 1,
id: Discord.getUUID(), id: Discord.RichPresence.getUUID(),
}) })
.setStartTimestamp(Date.now()) .setStartTimestamp(Date.now())
.setAssetsLargeImage('https://cdn.discordapp.com/attachments/820557032016969751/991172011483218010/unknown.png') .setAssetsLargeImage('https://cdn.discordapp.com/attachments/820557032016969751/991172011483218010/unknown.png')
@ -135,7 +135,7 @@ client.user.setActivity(r.toJSON());
```js ```js
const rpc = new Discord.RichPresence(); const rpc = new Discord.RichPresence();
const imageSet = await rpc.getExternal(client, '820344593357996092', 'https://musedash.moe/covers/papipupipupipa_cover.hash.93ae31d41.png', 'https://musedash.moe/covers/lights_of_muse_cover.hash.1c18e1e22.png') const imageSet = await Discord.RichPresence.getExternal(client, '820344593357996092', 'https://musedash.moe/covers/papipupipupipa_cover.hash.93ae31d41.png', 'https://musedash.moe/covers/lights_of_muse_cover.hash.1c18e1e22.png')
rpc rpc
.setApplicationId('820344593357996092') .setApplicationId('820344593357996092')
.setType('PLAYING') .setType('PLAYING')
@ -165,4 +165,4 @@ const asset = await bot.application.fetchAssets();
<img src='https://cdn.discordapp.com/attachments/820557032016969751/995307606115618926/unknown.png'> <img src='https://cdn.discordapp.com/attachments/820557032016969751/995307606115618926/unknown.png'>
- More: - More:
- You can change the status 5 times every 20 seconds! - You can change the status 5 times / 20 seconds!

View File

@ -473,7 +473,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
* Get random UUID string (Util) * Get random UUID string (Util)
* @returns {string} * @returns {string}
*/ */
getUUID() { static getUUID() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a => return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a =>
(a ^ ((Math.random() * 16) >> (a / 4))).toString(16), (a ^ ((Math.random() * 16) >> (a / 4))).toString(16),
); );
@ -487,7 +487,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
* @param {string} image2 URL image 2 (not from Discord) * @param {string} image2 URL image 2 (not from Discord)
* @returns {ExternalAssets[]} * @returns {ExternalAssets[]}
*/ */
async getExternal(client, applicationId, image1 = '', image2 = '') { static async getExternal(client, applicationId, image1 = '', image2 = '') {
const checkURL = url => { const checkURL = url => {
try { try {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new

4
typings/index.d.ts vendored
View File

@ -250,13 +250,13 @@ export abstract class RichPresence {
public setEndTimestamp(timestamp?: Date): this; public setEndTimestamp(timestamp?: Date): this;
public setButtons(...button: RichButton[]): this; public setButtons(...button: RichButton[]): this;
public addButton(name: string, url: string): this; public addButton(name: string, url: string): this;
public getExternal( public static getExternal(
client: Client, client: Client,
applicationId: Snowflake, applicationId: Snowflake,
image1: string, image1: string,
image2: string, image2: string,
): Promise<ExternalAssets[]>; ): Promise<ExternalAssets[]>;
public getUUID(): string; public static getUUID(): string;
public toJSON(): object; public toJSON(): object;
} }