@mafiahub/types 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/framework/discord.d.ts +153 -0
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
declare namespace Framework {
|
|
2
|
+
/** Activity verb shown before the app name. Name or the numeric Discord enum. */
|
|
3
|
+
type DiscordActivityType = "playing" | "streaming" | "listening" | "watching" | number;
|
|
4
|
+
|
|
5
|
+
/** Party join privacy. Name or the numeric Discord enum. */
|
|
6
|
+
type DiscordPartyPrivacy = "private" | "public" | number;
|
|
7
|
+
|
|
8
|
+
/** Options accepted by {@link Discord.setPresence}. Every field is optional. */
|
|
9
|
+
interface DiscordPresenceOptions {
|
|
10
|
+
/** Activity verb; defaults to `"playing"`. */
|
|
11
|
+
type?: DiscordActivityType;
|
|
12
|
+
/** Activity name. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Top line of the presence. */
|
|
15
|
+
details?: string;
|
|
16
|
+
/** Bottom line of the presence. */
|
|
17
|
+
state?: string;
|
|
18
|
+
/** Elapsed-time anchor, unix seconds. `0` clears it. */
|
|
19
|
+
startTimestamp?: number;
|
|
20
|
+
/** Countdown anchor, unix seconds. `0` clears it. */
|
|
21
|
+
endTimestamp?: number;
|
|
22
|
+
/** Asset key of the large image. */
|
|
23
|
+
largeImage?: string;
|
|
24
|
+
/** Tooltip for the large image. */
|
|
25
|
+
largeText?: string;
|
|
26
|
+
/** Asset key of the small image (overlaps the large one). */
|
|
27
|
+
smallImage?: string;
|
|
28
|
+
/** Tooltip for the small image. */
|
|
29
|
+
smallText?: string;
|
|
30
|
+
/** Party grouping — enables Discord "X of Y" and, with a join secret, invites. */
|
|
31
|
+
party?: {
|
|
32
|
+
id?: string;
|
|
33
|
+
/** `[current, max]` party size. */
|
|
34
|
+
size?: [number, number];
|
|
35
|
+
privacy?: DiscordPartyPrivacy;
|
|
36
|
+
};
|
|
37
|
+
/** Invite/spectate secrets (opaque strings your game round-trips). */
|
|
38
|
+
secrets?: {
|
|
39
|
+
match?: string;
|
|
40
|
+
join?: string;
|
|
41
|
+
spectate?: string;
|
|
42
|
+
};
|
|
43
|
+
/** Whether this is an instanced (session) activity. */
|
|
44
|
+
instance?: boolean;
|
|
45
|
+
/** Supported-platform bitmask (Desktop = 1, Android = 2, iOS = 4). */
|
|
46
|
+
supportedPlatforms?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Client-side Discord rich presence API. **Client only** — not available on
|
|
51
|
+
* the server.
|
|
52
|
+
*
|
|
53
|
+
* Field setters *stage* changes onto a pending activity; nothing is shown
|
|
54
|
+
* until {@link Discord.update} (or the batch {@link Discord.setPresence}) is
|
|
55
|
+
* called. This mirrors Discord's model — an activity is published as one whole
|
|
56
|
+
* object and updates are rate-limited — so compose, then commit once. All
|
|
57
|
+
* calls no-op (setters silently, commits return `false`) when Discord presence
|
|
58
|
+
* is disabled or unavailable.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Batch form — apply several fields and publish in one call:
|
|
62
|
+
* Framework.Discord.setPresence({
|
|
63
|
+
* details: "In the city",
|
|
64
|
+
* state: "Freeroam",
|
|
65
|
+
* largeImage: "map-city",
|
|
66
|
+
* startTimestamp: Math.floor(Date.now() / 1000),
|
|
67
|
+
* party: { size: [4, 32] },
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Granular form — stage, then commit:
|
|
72
|
+
* Framework.Discord.setDetails("Racing");
|
|
73
|
+
* Framework.Discord.setPartySize(2, 8);
|
|
74
|
+
* Framework.Discord.update();
|
|
75
|
+
*/
|
|
76
|
+
const Discord: {
|
|
77
|
+
/** Stage the activity {@link DiscordActivityType type}. */
|
|
78
|
+
setType(type: DiscordActivityType): void;
|
|
79
|
+
/** Stage the activity name. */
|
|
80
|
+
setName(name: string): void;
|
|
81
|
+
/** Stage the top line. */
|
|
82
|
+
setDetails(details: string): void;
|
|
83
|
+
/** Stage the bottom line. */
|
|
84
|
+
setState(state: string): void;
|
|
85
|
+
|
|
86
|
+
/** Stage the elapsed-time anchor (unix seconds; `0` clears). */
|
|
87
|
+
setStartTimestamp(seconds: number): void;
|
|
88
|
+
/** Stage the countdown anchor (unix seconds; `0` clears). */
|
|
89
|
+
setEndTimestamp(seconds: number): void;
|
|
90
|
+
|
|
91
|
+
/** Stage the large image asset key. */
|
|
92
|
+
setLargeImage(assetKey: string): void;
|
|
93
|
+
/** Stage the large image tooltip. */
|
|
94
|
+
setLargeText(text: string): void;
|
|
95
|
+
/** Stage the small image asset key. */
|
|
96
|
+
setSmallImage(assetKey: string): void;
|
|
97
|
+
/** Stage the small image tooltip. */
|
|
98
|
+
setSmallText(text: string): void;
|
|
99
|
+
/** Stage several asset fields at once. */
|
|
100
|
+
setAssets(assets: { largeImage?: string; largeText?: string; smallImage?: string; smallText?: string }): void;
|
|
101
|
+
|
|
102
|
+
/** Stage the party id. */
|
|
103
|
+
setPartyId(id: string): void;
|
|
104
|
+
/** Stage the party size (current of max). */
|
|
105
|
+
setPartySize(current: number, max: number): void;
|
|
106
|
+
/** Stage the party join privacy. */
|
|
107
|
+
setPartyPrivacy(privacy: DiscordPartyPrivacy): void;
|
|
108
|
+
/** Stage several party fields at once. */
|
|
109
|
+
setParty(party: { id?: string; size?: [number, number]; privacy?: DiscordPartyPrivacy }): void;
|
|
110
|
+
|
|
111
|
+
/** Stage the match secret. */
|
|
112
|
+
setMatchSecret(secret: string): void;
|
|
113
|
+
/** Stage the join secret (enables Ask to Join). */
|
|
114
|
+
setJoinSecret(secret: string): void;
|
|
115
|
+
/** Stage the spectate secret. */
|
|
116
|
+
setSpectateSecret(secret: string): void;
|
|
117
|
+
/** Stage several secret fields at once. */
|
|
118
|
+
setSecrets(secrets: { match?: string; join?: string; spectate?: string }): void;
|
|
119
|
+
|
|
120
|
+
/** Stage the instanced flag. */
|
|
121
|
+
setInstance(instance: boolean): void;
|
|
122
|
+
/** Stage the supported-platform bitmask (Desktop = 1, Android = 2, iOS = 4). */
|
|
123
|
+
setSupportedPlatforms(flags: number): void;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Apply a batch of fields and publish immediately (a merge of the matching
|
|
127
|
+
* setters followed by {@link Discord.update}).
|
|
128
|
+
* @returns `true` if the update was dispatched, `false` if unavailable.
|
|
129
|
+
*/
|
|
130
|
+
setPresence(options: DiscordPresenceOptions): boolean;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Publish the currently staged activity.
|
|
134
|
+
* @returns `true` if dispatched, `false` if unavailable.
|
|
135
|
+
*/
|
|
136
|
+
update(): boolean;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Clear the activity on Discord and reset the staged state.
|
|
140
|
+
* @returns `true` if dispatched, `false` if unavailable.
|
|
141
|
+
*/
|
|
142
|
+
clear(): boolean;
|
|
143
|
+
|
|
144
|
+
/** Reset the staged state without publishing. */
|
|
145
|
+
reset(): void;
|
|
146
|
+
|
|
147
|
+
/** Snowflake of the signed-in Discord user, or `""` until known. */
|
|
148
|
+
getUserId(): string;
|
|
149
|
+
|
|
150
|
+
/** Whether the Discord client is connected and presence can be published. */
|
|
151
|
+
isAvailable(): boolean;
|
|
152
|
+
};
|
|
153
|
+
}
|
package/index.d.ts
CHANGED