feat: new RPC

This commit is contained in:
Elysia
2024-01-31 20:54:42 +07:00
parent 585b71a1af
commit 987aa3a1fb
8 changed files with 870 additions and 968 deletions

217
typings/index.d.ts vendored
View File

@@ -173,28 +173,16 @@ export interface RichButton {
url: string;
}
export class RichPresence {
public constructor(client?: Client, data?: object, IPC?: boolean);
public application_id: Snowflake | null;
public assets: RichPresenceAssets | null;
public buttons: string[];
public details: string | null;
public name: string;
public party: {
id: string | null;
size: [number, number];
} | null;
public state: string | null;
public timestamps: {
start: Date | null;
end: Date | null;
} | null;
public type: ActivityType;
public url: string | null;
public ipc: boolean;
export class RichPresence extends Activity {
public constructor(client: Client, data?: object);
public metadata: RichPresenceMetadata;
/** @deprecated */
public setAssetsLargeImage(image?: string): this;
/** @deprecated */
public setAssetsLargeText(text?: string): this;
/** @deprecated */
public setAssetsSmallImage(image?: string): this;
/** @deprecated */
public setAssetsSmallText(text?: string): this;
public setName(name?: string): this;
public setURL(url?: string): this;
@@ -203,8 +191,8 @@ export class RichPresence {
public setDetails(details?: string): this;
public setState(state?: string): this;
public setParty(party?: { max: number; current: number; id?: string }): this;
public setStartTimestamp(timestamp?: Date): this;
public setEndTimestamp(timestamp?: Date): this;
public setStartTimestamp(timestamp: Date | number | null): this;
public setEndTimestamp(timestamp: Date | number | null): this;
public setButtons(...button: RichButton[]): this;
public addButton(name: string, url: string): this;
public static getExternal(
@@ -243,62 +231,39 @@ export interface ExternalAssets {
external_asset_path: string;
}
export interface SpotifyMetadata {
album_id: string;
artist_ids: string[];
export interface RichPresenceMetadata {
album_id?: string;
artist_ids?: string[];
context_uri?: string;
button_urls?: string[];
}
export class SpotifyRPC extends RichPresence {
public constructor(client: Client, data?: object);
public application_id: Snowflake | null;
public client: Client;
public assets: RichPresenceAssets | null;
public buttons: string[];
public details: string | null;
public name: string;
public sync_id: string;
public id: string;
public flags: number;
public party: {
id: string | null;
size: [number, number];
} | null;
public state: string | null;
public timestamps: {
start: Date | null;
end: Date | null;
} | null;
public type: ActivityType;
public url: string | null;
public metadata: SpotifyMetadata;
public setAssetsLargeImage(image?: string): this;
public setAssetsSmallImage(image?: string): this;
public setSongId(id: string): this;
public addArtistId(id: string): this;
public setArtistIds(...ids: string[]): this;
public setAlbumId(id: string): this;
}
export class CustomStatus {
public constructor(data?: object);
public emoji: EmojiIdentifierResolvable;
public state: string;
export class CustomStatus extends Activity {
public constructor(client: Client, data?: object);
public setEmoji(emoji?: EmojiIdentifierResolvable): this;
public setState(state: string): this;
public toJSON(): object;
public toString(): string;
public toJSON(): unknown;
}
export class Activity {
private constructor(presence: Presence, data?: RawActivityData);
public constructor(presence: Presence, data?: RawActivityData);
public readonly presence: Presence;
public applicationId: Snowflake | null;
public assets: RichPresenceAssets | null;
public assets: RichPresenceAssets;
public buttons: string[];
public readonly createdAt: Date;
public createdTimestamp: number;
public details: string | null;
public emoji: Emoji | null;
public emoji: EmojiIdentifierResolvable | null;
public flags: Readonly<ActivityFlags>;
public id: string;
public name: string;
@@ -311,8 +276,8 @@ export class Activity {
public state: string | null;
public syncId: string | null;
public timestamps: {
start: Date | null;
end: Date | null;
start: number | null;
end: number | null;
} | null;
public type: ActivityType;
public url: string | null;
@@ -1320,16 +1285,16 @@ export class GuildAuditLogs<T extends GuildAuditLogsResolvable = 'ALL'> {
export class GuildAuditLogsEntry<
TActionRaw extends GuildAuditLogsResolvable = 'ALL',
TAction = TActionRaw extends keyof GuildAuditLogsIds
? GuildAuditLogsIds[TActionRaw]
: TActionRaw extends null
? 'ALL'
: TActionRaw,
? GuildAuditLogsIds[TActionRaw]
: TActionRaw extends null
? 'ALL'
: TActionRaw,
TActionType extends GuildAuditLogsActionType = TAction extends keyof GuildAuditLogsTypes
? GuildAuditLogsTypes[TAction][1]
: 'ALL',
? GuildAuditLogsTypes[TAction][1]
: 'ALL',
TTargetType extends GuildAuditLogsTarget = TAction extends keyof GuildAuditLogsTypes
? GuildAuditLogsTypes[TAction][0]
: 'UNKNOWN',
? GuildAuditLogsTypes[TAction][0]
: 'UNKNOWN',
> {
private constructor(guild: Guild, data: RawGuildAuditLogEntryData, logs?: GuildAuditLogs);
public action: TAction;
@@ -1586,7 +1551,7 @@ export class HTTPError extends Error {
}
// tslint:disable-next-line:no-empty-interface - Merge RateLimitData into RateLimitError to not have to type it again
export interface RateLimitError extends RateLimitData {}
export interface RateLimitError extends RateLimitData { }
export class RateLimitError extends Error {
private constructor(data: RateLimitData);
public name: 'RateLimitError';
@@ -1930,8 +1895,8 @@ export class MessageActionRow<
T extends MessageActionRowComponent | ModalActionRowComponent = MessageActionRowComponent,
U = T extends ModalActionRowComponent ? ModalActionRowComponentResolvable : MessageActionRowComponentResolvable,
V = T extends ModalActionRowComponent
? APIActionRowComponent<APIModalActionRowComponent>
: APIActionRowComponent<APIMessageActionRowComponent>,
? APIActionRowComponent<APIModalActionRowComponent>
: APIActionRowComponent<APIMessageActionRowComponent>,
> extends BaseMessageComponent {
// tslint:disable-next-line:ban-ts-ignore
// @ts-ignore (TS:2344, Caused by TypeScript 4.8)
@@ -2481,6 +2446,12 @@ export class RichPresenceAssets {
public smallText: string | null;
public largeImageURL(options?: StaticImageURLOptions): string | null;
public smallImageURL(options?: StaticImageURLOptions): string | null;
public static parseImage(image: string): string | null;
public toJSON(): unknown;
public setLargeImage(image?: string): this;
public setLargeText(text?: string): this;
public setSmallImage(image?: string): this;
public setSmallText(text?: string): this;
}
export class Role extends Base {
@@ -3715,13 +3686,13 @@ export class ApplicationCommandPermissionsManager<
public remove(
options:
| (FetchSingleOptions & {
users: UserResolvable | UserResolvable[];
roles?: RoleResolvable | RoleResolvable[];
})
users: UserResolvable | UserResolvable[];
roles?: RoleResolvable | RoleResolvable[];
})
| (FetchSingleOptions & {
users?: UserResolvable | UserResolvable[];
roles: RoleResolvable | RoleResolvable[];
}),
users?: UserResolvable | UserResolvable[];
roles: RoleResolvable | RoleResolvable[];
}),
): Promise<ApplicationCommandPermissions[]>;
public set(
options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] },
@@ -4658,12 +4629,12 @@ export interface ApplicationCommandChannelOption extends BaseApplicationCommandO
export interface ApplicationCommandAutocompleteOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type:
| 'STRING'
| 'NUMBER'
| 'INTEGER'
| ApplicationCommandOptionTypes.STRING
| ApplicationCommandOptionTypes.NUMBER
| ApplicationCommandOptionTypes.INTEGER;
| 'STRING'
| 'NUMBER'
| 'INTEGER'
| ApplicationCommandOptionTypes.STRING
| ApplicationCommandOptionTypes.NUMBER
| ApplicationCommandOptionTypes.INTEGER;
autocomplete: true;
}
@@ -4935,9 +4906,9 @@ export interface AutoModerationRuleCreateOptions {
reason?: string;
}
export interface AutoModerationRuleEditOptions extends Partial<Omit<AutoModerationRuleCreateOptions, 'triggerType'>> {}
export interface AutoModerationRuleEditOptions extends Partial<Omit<AutoModerationRuleCreateOptions, 'triggerType'>> { }
export interface AutoModerationTriggerMetadataOptions extends Partial<AutoModerationTriggerMetadata> {}
export interface AutoModerationTriggerMetadataOptions extends Partial<AutoModerationTriggerMetadata> { }
export interface AutoModerationActionOptions {
type: AutoModerationActionType | AutoModerationActionTypes;
@@ -5044,8 +5015,8 @@ export type CacheFactory = (
export type CacheWithLimitsOptions = {
[K in keyof Caches]?: Caches[K][0]['prototype'] extends DataManager<infer K, infer V, any>
? LimitedCollectionOptions<K, V> | number
: never;
? LimitedCollectionOptions<K, V> | number
: never;
};
export interface CategoryCreateChannelOptions {
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
@@ -5398,12 +5369,12 @@ export interface ConstantsClientApplicationAssetTypes {
export type AutocompleteFocusedOption = Pick<CommandInteractionOption, 'name'> & {
focused: true;
type:
| 'STRING'
| 'INTEGER'
| 'NUMBER'
| ApplicationCommandOptionTypes.STRING
| ApplicationCommandOptionTypes.INTEGER
| ApplicationCommandOptionTypes.NUMBER;
| 'STRING'
| 'INTEGER'
| 'NUMBER'
| ApplicationCommandOptionTypes.STRING
| ApplicationCommandOptionTypes.INTEGER
| ApplicationCommandOptionTypes.NUMBER;
value: string;
};
@@ -5962,20 +5933,20 @@ export interface GuildAuditLogsEntryExtraField {
MESSAGE_UNPIN: { channel: GuildTextBasedChannel | { id: Snowflake }; messageId: Snowflake };
MEMBER_DISCONNECT: { count: number };
CHANNEL_OVERWRITE_CREATE:
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteTypes.role }
| { id: Snowflake; type: OverwriteTypes.member };
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteTypes.role }
| { id: Snowflake; type: OverwriteTypes.member };
CHANNEL_OVERWRITE_UPDATE:
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteTypes.role }
| { id: Snowflake; type: OverwriteTypes.member };
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteTypes.role }
| { id: Snowflake; type: OverwriteTypes.member };
CHANNEL_OVERWRITE_DELETE:
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteTypes.role }
| { id: Snowflake; type: OverwriteTypes.member };
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteTypes.role }
| { id: Snowflake; type: OverwriteTypes.member };
STAGE_INSTANCE_CREATE: StageChannel | { id: Snowflake };
STAGE_INSTANCE_DELETE: StageChannel | { id: Snowflake };
STAGE_INSTANCE_UPDATE: StageChannel | { id: Snowflake };
@@ -6006,8 +5977,8 @@ export interface GuildAuditLogsEntryTargetField<TActionType extends GuildAuditLo
INVITE: Invite;
MESSAGE: TActionType extends 'MESSAGE_BULK_DELETE' ? Guild | { id: Snowflake } : User;
INTEGRATION: Integration;
CHANNEL: NonThreadGuildBasedChannel | { id: Snowflake; [x: string]: unknown };
THREAD: ThreadChannel | { id: Snowflake; [x: string]: unknown };
CHANNEL: NonThreadGuildBasedChannel | { id: Snowflake;[x: string]: unknown };
THREAD: ThreadChannel | { id: Snowflake;[x: string]: unknown };
STAGE_INSTANCE: StageInstance;
STICKER: Sticker;
GUILD_SCHEDULED_EVENT: GuildScheduledEvent;
@@ -6245,8 +6216,8 @@ export type GuildScheduledEventManagerFetchResult<
export type GuildScheduledEventManagerFetchSubscribersResult<T extends FetchGuildScheduledEventSubscribersOptions> =
T extends { withMember: true }
? Collection<Snowflake, GuildScheduledEventUser<true>>
: Collection<Snowflake, GuildScheduledEventUser<false>>;
? Collection<Snowflake, GuildScheduledEventUser<true>>
: Collection<Snowflake, GuildScheduledEventUser<false>>;
export type GuildScheduledEventPrivacyLevel = keyof typeof GuildScheduledEventPrivacyLevels;
@@ -6433,8 +6404,8 @@ export type ModalActionRowComponentResolvable =
export interface MessageActionRowOptions<
T extends
| MessageActionRowComponentResolvable
| ModalActionRowComponentResolvable = MessageActionRowComponentResolvable,
| MessageActionRowComponentResolvable
| ModalActionRowComponentResolvable = MessageActionRowComponentResolvable,
> extends BaseMessageComponentOptions {
components: T[];
}
@@ -6685,8 +6656,8 @@ export type MFALevel = keyof typeof MFALevels;
export interface ModalOptions {
components:
| MessageActionRow<ModalActionRowComponent>[]
| MessageActionRowOptions<ModalActionRowComponentResolvable>[];
| MessageActionRow<ModalActionRowComponent>[]
| MessageActionRowOptions<ModalActionRowComponentResolvable>[];
customId: string;
title: string;
}
@@ -6849,19 +6820,19 @@ export type Partialize<
id: Snowflake;
partial: true;
} & {
[K in keyof Omit<T, 'client' | 'id' | 'partial' | E>]: K extends N ? null : K extends M ? T[K] | null : T[K];
};
[K in keyof Omit<T, 'client' | 'id' | 'partial' | E>]: K extends N ? null : K extends M ? T[K] | null : T[K];
};
export interface PartialDMChannel extends Partialize<DMChannel, null, null, 'lastMessageId'> {
lastMessageId: undefined;
}
export interface PartialGuildMember extends Partialize<GuildMember, 'joinedAt' | 'joinedTimestamp'> {}
export interface PartialGuildMember extends Partialize<GuildMember, 'joinedAt' | 'joinedTimestamp'> { }
export interface PartialMessage
extends Partialize<Message, 'type' | 'system' | 'pinned' | 'tts', 'content' | 'cleanContent' | 'author'> {}
extends Partialize<Message, 'type' | 'system' | 'pinned' | 'tts', 'content' | 'cleanContent' | 'author'> { }
export interface PartialMessageReaction extends Partialize<MessageReaction, 'count'> {}
export interface PartialMessageReaction extends Partialize<MessageReaction, 'count'> { }
export interface PartialOverwriteData {
id: Snowflake | number;
@@ -6876,7 +6847,7 @@ export interface PartialRoleData extends RoleData {
export type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION' | 'GUILD_SCHEDULED_EVENT';
export interface PartialUser extends Partialize<User, 'username' | 'tag' | 'discriminator'> {}
export interface PartialUser extends Partialize<User, 'username' | 'tag' | 'discriminator'> { }
export type PresenceStatusData = ClientPresenceStatus | 'invisible';
@@ -7070,8 +7041,8 @@ export interface SweeperDefinitions {
export type SweeperOptions = {
[K in keyof SweeperDefinitions]?: SweeperDefinitions[K][2] extends true
? SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]> | LifetimeSweepOptions
: SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]>;
? SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]> | LifetimeSweepOptions
: SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]>;
};
export interface LimitedCollectionOptions<K, V> {
@@ -7210,12 +7181,12 @@ export interface WebhookClientDataURL {
export type FriendRequestOptions =
| {
user: UserResolvable;
}
user: UserResolvable;
}
| {
username: string;
discriminator: number | null;
};
username: string;
discriminator: number | null;
};
export type WebhookClientOptions = Pick<
ClientOptions,