RichPresence Testing 1
This commit is contained in:
parent
1cc36e429e
commit
4d247119f4
@ -142,6 +142,13 @@ Guild
|
||||
```
|
||||
</details>
|
||||
|
||||
## Custom Status and RPC
|
||||
|
||||
<details>
|
||||
<summary><strong>Click to show</strong></summary>
|
||||
- Document come soon !
|
||||
</details>
|
||||
|
||||
## More features
|
||||
|
||||
<details>
|
||||
|
208
RPC/index.d.ts
vendored
Normal file
208
RPC/index.d.ts
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
declare class RpcError extends Error {
|
||||
name: string;
|
||||
}
|
||||
declare class Rpc {
|
||||
game: discordPresence | null;
|
||||
constructor(rpcObj?: discordPresence | null, readonly?: boolean);
|
||||
lock(): void;
|
||||
toDiscord(): {
|
||||
game: discordPresence | null;
|
||||
};
|
||||
toObject(): discordPresence;
|
||||
toString(): string;
|
||||
setName(name: string | null): this;
|
||||
setApplicationId(id: string | null): this;
|
||||
setType(type: PresenceType | number): this;
|
||||
setUrl(url: string | null): this;
|
||||
setDetails(details: string | null): this;
|
||||
setState(state: string | null): this;
|
||||
setSyncId(sync_id: string | null): this;
|
||||
setId(id: string | null): this;
|
||||
setSessionId(session_id: string | null): this;
|
||||
setParty(party: discordPresence["party"]): this;
|
||||
setFlags(flags: number | null): this;
|
||||
setCreatedAt(created_at: number | null): this;
|
||||
setAssets(assetsFunc: (AssetsObj: setAssetsObj) => void): Rpc;
|
||||
/**
|
||||
*
|
||||
* @param large_image *ID image*
|
||||
*/
|
||||
setAssetsLargeImage(large_image: string | null): this;
|
||||
/**
|
||||
*
|
||||
* @param large_image *ID image*
|
||||
*/
|
||||
setAssetsSmallImage(small_image: string | null): this;
|
||||
setAssetsLargeText(large_text: string | null): this;
|
||||
setAssetsSmallText(small_text: string | null): this;
|
||||
setStartTimestamp(start: number | null): this;
|
||||
setEndTimestamp(end: number | null): this;
|
||||
setPartySize(size: [number, number] | null): this;
|
||||
setPartyId(id: string | null): this;
|
||||
setJoinSecret(secret: string | null): this;
|
||||
setSpectateSecret(secret: string | null): this;
|
||||
setMatch(secret: string | null): this;
|
||||
setSecrets(secrets: discordPresence["secrets"] | null): this;
|
||||
/**
|
||||
* Twitch
|
||||
*/
|
||||
setTwitchAssets(assetsFunc: (AssetsObj: setAssetsObj) => void): Rpc;
|
||||
/**
|
||||
*
|
||||
* @param large_image *ID Image*
|
||||
*/
|
||||
setTwitchAssetsLargeImage(large_image: string | null): this;
|
||||
/**
|
||||
*
|
||||
* @param large_image *ID Image*
|
||||
*/
|
||||
setTwitchAssetsSmallImage(small_image: string | null): this;
|
||||
/** Spotify */
|
||||
setSpotifyAssets(assetsFunc: (AssetsObj: setAssetsObj) => void): Rpc;
|
||||
/**
|
||||
*
|
||||
* @param large_image *ID Image*
|
||||
*/
|
||||
setSpotifyAssetsLargeImage(large_image: string | null): this;
|
||||
/**
|
||||
*
|
||||
* @param large_image *ID Image*
|
||||
*/
|
||||
setSpotifyAssetsSmallImage(small_image: string | null): this;
|
||||
private verifyNull;
|
||||
private verifyNullAssets;
|
||||
private verifyNullTimestamps;
|
||||
private verifyNullParty;
|
||||
private verifyNullSecrets;
|
||||
}
|
||||
declare class CustomStatus {
|
||||
game: CustomStatusGame;
|
||||
constructor(CustomStatusGame?: CustomStatusGame);
|
||||
/**
|
||||
* Name
|
||||
* @param state Name of the status
|
||||
*/
|
||||
setState(state: string): CustomStatus;
|
||||
/**
|
||||
* Custom Status with Emoji Custom
|
||||
* @param emoji Object
|
||||
* emoji.name: string
|
||||
* emoji.id: string
|
||||
* emoji.animated: boolean
|
||||
*/
|
||||
setDiscordEmoji(emoji: emojiLike): CustomStatus;
|
||||
/**
|
||||
* Unicode Emoji
|
||||
* @param emoji String
|
||||
*/
|
||||
setUnicodeEmoji(emoji: string): CustomStatus;
|
||||
/** Convert to JSON Activity */
|
||||
toDiscord(): CustomStatusGame;
|
||||
toObject(): CustomStatusGame;
|
||||
toString(): string;
|
||||
}
|
||||
interface setEmojiObj {
|
||||
setName(name: string): setEmojiObj;
|
||||
setId(id: string): setEmojiObj;
|
||||
setAnimated(animated: boolean): setEmojiObj;
|
||||
}
|
||||
interface setAssetsObj {
|
||||
setLargeImage(img: string | null): setAssetsObj;
|
||||
setSmallImage(img: string | null): setAssetsObj;
|
||||
setLargeText(text: string | null): setAssetsObj;
|
||||
setSmallText(text: string | null): setAssetsObj;
|
||||
setNull(): setAssetsObj;
|
||||
}
|
||||
interface CustomStatusGame {
|
||||
name: string;
|
||||
emoji: {
|
||||
name: string;
|
||||
id: string | null;
|
||||
animated: boolean;
|
||||
} | null;
|
||||
state: string;
|
||||
}
|
||||
interface rpcManager {
|
||||
default?: rpcManager;
|
||||
Rpc: {
|
||||
new (rpcobj?: discordPresence): Rpc;
|
||||
};
|
||||
PresenceTypes: PresenceType[];
|
||||
PresenceTypesString: PresenceTypeString[];
|
||||
PresenceTypesNumber: PresenceTypeNumber[];
|
||||
RpcError: {
|
||||
new (message: string): RpcError;
|
||||
};
|
||||
getRpcImages(application_id: string): Promise<Image[]>;
|
||||
getRpcImage(application_id: string, name: string): Promise<Image>;
|
||||
__esModule: true;
|
||||
createSpotifyRpc(client: clientLike, rpcobj?: discordPresence): Rpc;
|
||||
version: string;
|
||||
CustomStatus: {
|
||||
new (CustomStatusGame?: CustomStatusGame): CustomStatus;
|
||||
};
|
||||
}
|
||||
interface emojiLike {
|
||||
id: string;
|
||||
animated: boolean;
|
||||
name: string;
|
||||
[k: string]: any;
|
||||
}
|
||||
interface clientLike {
|
||||
ws: {
|
||||
connection: {
|
||||
sessionID: string;
|
||||
[k: string]: any;
|
||||
};
|
||||
[k: string]: any;
|
||||
};
|
||||
user: {
|
||||
id: string;
|
||||
[k: string]: any;
|
||||
};
|
||||
[k: string]: any;
|
||||
}
|
||||
interface discordPresence {
|
||||
"name": string;
|
||||
"platform"?: string;
|
||||
"application_id"?: string;
|
||||
"type": PresenceTypeNumber;
|
||||
"url"?: string;
|
||||
"details"?: string;
|
||||
"state"?: string;
|
||||
"sync_id"?: string;
|
||||
"id"?: string;
|
||||
"session_id"?: string;
|
||||
"party"?: {
|
||||
"size"?: [number, number];
|
||||
"id": string;
|
||||
};
|
||||
"flags"?: number;
|
||||
"created_at"?: number;
|
||||
"assets"?: {
|
||||
"large_image"?: string;
|
||||
"small_image"?: string;
|
||||
"small_text"?: string;
|
||||
"large_text"?: string;
|
||||
};
|
||||
"timestamps"?: {
|
||||
"start"?: number;
|
||||
"end"?: number;
|
||||
};
|
||||
"secrets"?: {
|
||||
"join"?: string;
|
||||
"spectate"?: string;
|
||||
"match"?: string;
|
||||
};
|
||||
}
|
||||
/** getRPC {@link getRpcImage} */
|
||||
declare type Image = {
|
||||
name: string;
|
||||
id: string;
|
||||
type: number;
|
||||
};
|
||||
declare type PresenceTypeString = "PLAYING" | "STREAMING" | "LISTENING" | "WATCHING" | "CUSTOM" | "COMPETING";
|
||||
declare type PresenceTypeNumber = 0 | 1 | 2 | 3 | 4 | 5;
|
||||
declare type PresenceType = PresenceTypeNumber | PresenceTypeString;
|
||||
declare var rpcManager: rpcManager;
|
||||
export = rpcManager;
|
1849
RPC/index.js
Normal file
1849
RPC/index.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord.js-selfbot-v13",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.8",
|
||||
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
||||
"main": "./src/index.js",
|
||||
"types": "./typings/index.d.ts",
|
||||
|
@ -5,7 +5,7 @@ const User = require('../../../structures/User');
|
||||
let ClientUser;
|
||||
const chalk = require('chalk');
|
||||
const axios = require('axios');
|
||||
const Discord = require('discord.js-selfbot-v13');
|
||||
const Discord = require('../../../index');
|
||||
|
||||
const checkUpdate = async () => {
|
||||
const res_ = await axios.get(
|
||||
@ -43,7 +43,28 @@ module.exports = (client, { d: data }, shard) => {
|
||||
|
||||
client.user.setAFK(true);
|
||||
|
||||
client.setting.fetch();
|
||||
client.setting.fetch()
|
||||
.then(async res => {
|
||||
let custom_status;
|
||||
if (
|
||||
res.rawSetting.custom_status?.text ||
|
||||
res.rawSetting.custom_status?.emoji_name
|
||||
) {
|
||||
custom_status = new Discord.RichPresence.CustomStatus();
|
||||
if (res.rawSetting.custom_status.emoji_id) {
|
||||
const emoji = await client.emojis.resolve(
|
||||
res.rawSetting.custom_status.emoji_id,
|
||||
);
|
||||
if (emoji) custom_status.setDiscordEmoji(emoji);
|
||||
} else {
|
||||
custom_status.setUnicodeEmoji(res.rawSetting.custom_status.emoji_name);
|
||||
}
|
||||
}
|
||||
client.user.setPresence({
|
||||
activities: custom_status ? [custom_status.toDiscord()] : [],
|
||||
status: res.rawSetting.status,
|
||||
});
|
||||
})
|
||||
|
||||
for (const guild of data.guilds) {
|
||||
guild.shardId = shard.id;
|
||||
|
@ -9,6 +9,7 @@ exports.ShardingManager = require('./sharding/ShardingManager');
|
||||
exports.WebhookClient = require('./client/WebhookClient');
|
||||
|
||||
// Utilities
|
||||
exports.RichPresence = require('../RPC/index');
|
||||
exports.ActivityFlagsBitField = require('./util/ActivityFlagsBitField');
|
||||
exports.ApplicationFlagsBitField = require('./util/ApplicationFlagsBitField');
|
||||
exports.BaseManager = require('./managers/BaseManager');
|
||||
@ -43,6 +44,7 @@ exports.BaseGuildEmojiManager = require('./managers/BaseGuildEmojiManager');
|
||||
exports.CachedManager = require('./managers/CachedManager');
|
||||
exports.ChannelManager = require('./managers/ChannelManager');
|
||||
exports.ClientVoiceManager = require('./client/voice/ClientVoiceManager');
|
||||
exports.ClientUserSettingManager = require('./managers/ClientUserSettingManager');
|
||||
exports.DataManager = require('./managers/DataManager');
|
||||
exports.GuildApplicationCommandManager = require('./managers/GuildApplicationCommandManager');
|
||||
exports.GuildBanManager = require('./managers/GuildBanManager');
|
||||
|
@ -10,7 +10,7 @@ const { TypeError } = require('../errors');
|
||||
*/
|
||||
class ClientPresence extends Presence {
|
||||
constructor(client, data = {}) {
|
||||
super(client, Object.assign(data, { status: data.status ?? 'online', user: { id: null } }));
|
||||
super(client, Object.assign(data, { status: data.status || client.setting.status || 'online', user: { id: null } }));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,6 +21,7 @@ class ClientPresence extends Presence {
|
||||
set(presence) {
|
||||
const packet = this._parse(presence);
|
||||
this._patch(packet);
|
||||
console.log(packet);
|
||||
if (typeof presence.shardId === 'undefined') {
|
||||
this.client.ws.broadcast({ op: GatewayOpcodes.PresenceUpdate, d: packet });
|
||||
} else if (Array.isArray(presence.shardId)) {
|
||||
@ -50,21 +51,18 @@ class ClientPresence extends Presence {
|
||||
for (const [i, activity] of activities.entries()) {
|
||||
if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string');
|
||||
activity.type ??= 0;
|
||||
|
||||
data.activities.push({
|
||||
type: activity.type,
|
||||
name: activity.name,
|
||||
url: activity.url,
|
||||
});
|
||||
data.activities.push(activity);
|
||||
}
|
||||
} else if (!activities && (status || afk || since) && this.activities.length) {
|
||||
data.activities.push(
|
||||
...this.activities.map(a => ({
|
||||
name: a.name,
|
||||
type: a.type,
|
||||
url: a.url ?? undefined,
|
||||
})),
|
||||
);
|
||||
...this.activities.map((a) =>
|
||||
Object.assign(a, {
|
||||
name: a.name,
|
||||
type: a.type,
|
||||
url: a.url ?? undefined,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
Loading…
Reference in New Issue
Block a user