@discordjs/rpc 0.2.0-dev.1786968995-99af6d8be → 0.2.0-dev.1788538586-ecea9ed57
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/README.md +70 -0
- package/dist/index.d.ts +465 -0
- package/dist/index.js +688 -0
- package/dist/index.js.map +1 -0
- package/package.json +18 -17
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<br />
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
<br />
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://discord.gg/djs"><img src="https://img.shields.io/badge/join_us-on_discord-5865F2?logo=discord&logoColor=white" alt="Discord server" /></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@discordjs/rpc"><img src="https://img.shields.io/npm/v/@discordjs/rpc.svg?maxAge=3600" alt="npm version" /></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@discordjs/rpc"><img src="https://img.shields.io/npm/dt/@discordjs/rpc.svg?maxAge=3600" alt="npm downloads" /></a>
|
|
11
|
+
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/tests.yml/badge.svg" alt="Tests status" /></a>
|
|
12
|
+
<a href="https://github.com/discordjs/discord.js/commits/main/packages/rpc"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Frpc" /></a>
|
|
13
|
+
<a href="https://opencollective.com/discordjs"><img src="https://img.shields.io/opencollective/backers/discordjs?maxAge=3600&logo=opencollective" alt="backers" /></a>
|
|
14
|
+
<a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=rpc" alt="Code coverage" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
<p>
|
|
17
|
+
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
|
18
|
+
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
## About
|
|
23
|
+
|
|
24
|
+
`@discordjs/rpc` is a simple RPC client for Discord. It connects to the Discord desktop client running on the same machine over IPC, letting your application set a Rich Presence, react to client events, and call any [RPC command](https://docs.discord.com/developers/topics/rpc).
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
**Node.js 24.17.0 or newer is required.**
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @discordjs/rpc
|
|
32
|
+
yarn add @discordjs/rpc
|
|
33
|
+
pnpm add @discordjs/rpc
|
|
34
|
+
bun add @discordjs/rpc
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Links
|
|
38
|
+
|
|
39
|
+
- [Website][website] ([source][website-source])
|
|
40
|
+
- [Documentation][documentation]
|
|
41
|
+
- [Guide][guide] ([source][guide-source])
|
|
42
|
+
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
|
43
|
+
- [discord.js Discord server][discord]
|
|
44
|
+
- [Discord Developers Discord server][discord-developers]
|
|
45
|
+
- [GitHub][source]
|
|
46
|
+
- [npm][npm]
|
|
47
|
+
- [Related libraries][related-libs]
|
|
48
|
+
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
51
|
+
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
|
52
|
+
[documentation][documentation].
|
|
53
|
+
See [the contribution guide][contributing] if you'd like to submit a PR.
|
|
54
|
+
|
|
55
|
+
## Help
|
|
56
|
+
|
|
57
|
+
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
|
|
58
|
+
|
|
59
|
+
[website]: https://discord.js.org
|
|
60
|
+
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
|
61
|
+
[documentation]: https://discord.js.org/docs/packages/rpc/stable
|
|
62
|
+
[guide]: https://discordjs.guide
|
|
63
|
+
[guide-source]: https://github.com/discordjs/discord.js/tree/main/apps/guide
|
|
64
|
+
[guide-update]: https://discordjs.guide/legacy/additional-info/changes-in-v14
|
|
65
|
+
[discord]: https://discord.gg/djs
|
|
66
|
+
[discord-developers]: https://discord.gg/discord-developers
|
|
67
|
+
[source]: https://github.com/discordjs/discord.js/tree/main/packages/rpc
|
|
68
|
+
[npm]: https://www.npmjs.com/package/@discordjs/rpc
|
|
69
|
+
[related-libs]: https://docs.discord.com/developers/developer-tools/community-resources#libraries
|
|
70
|
+
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import * as discord_api_types_v10 from 'discord-api-types/v10';
|
|
2
|
+
import { RPCEvents, RPCSubscribeActivityInviteArgs, RPCSubscribeActivityJoinArgs, RPCSubscribeActivityJoinRequestArgs, RPCSubscribeActivitySpectateArgs, RPCSubscribeChannelCreateArgs, RPCSubscribeCurrentUserUpdateArgs, RPCSubscribeEntitlementCreateArgs, RPCSubscribeEntitlementDeleteArgs, RPCSubscribeGameJoinArgs, RPCSubscribeGameSpectateArgs, RPCSubscribeGuildCreateArgs, RPCSubscribeGuildStatusArgs, RPCSubscribeMessageCreateArgs, RPCSubscribeMessageDeleteArgs, RPCSubscribeMessageUpdateArgs, RPCSubscribeNotificationCreateArgs, RPCSubscribeOverlayArgs, RPCSubscribeOverlayUpdateArgs, RPCSubscribeRelationshipUpdateArgs, RPCSubscribeSpeakingStartArgs, RPCSubscribeSpeakingStopArgs, RPCSubscribeVoiceChannelSelectArgs, RPCSubscribeVoiceConnectionStatusArgs, RPCSubscribeVoiceSettingsUpdateArgs, RPCSubscribeVoiceSettingsUpdate2Args, RPCSubscribeVoiceStateCreateArgs, RPCSubscribeVoiceStateDeleteArgs, RPCSubscribeVoiceStateUpdateArgs, RPCActivityInviteDispatchData, RPCActivityJoinDispatchData, RPCActivityJoinRequestDispatchData, RPCActivitySpectateDispatchData, RPCChannelCreateDispatchData, RPCCurrentUserUpdateDispatchData, RPCEntitlementCreateDispatchData, RPCEntitlementDeleteDispatchData, RPCErrorDispatchData, RPCGameJoinDispatchData, RPCGameSpectateDispatchData, RPCGuildCreateDispatchData, RPCGuildStatusDispatchData, RPCMessageCreateDispatchData, RPCMessageDeleteDispatchData, RPCMessageUpdateDispatchData, RPCNotificationCreateDispatchData, RPCOverlayDispatchData, RPCOverlayUpdateDispatchData, RPCReadyDispatchData, RPCRelationshipUpdateDispatchData, RPCSpeakingStartDispatchData, RPCSpeakingStopDispatchData, RPCVoiceChannelSelectDispatchData, RPCVoiceConnectionStatusDispatchData, RPCVoiceSettingsUpdateDispatchData, RPCVoiceSettingsUpdate2DispatchData, RPCVoiceStateCreateDispatchData, RPCVoiceStateDeleteDispatchData, RPCVoiceStateUpdateDispatchData, RPCCommands, RPCAuthorizeArgs, RPCAuthenticateArgs, RPCGetChannelArgs, RPCGetChannelsArgs, RPCGetGuildArgs, RPCGetGuildsArgs, RPCGetUserArgs, RPCGetVoiceSettingsArgs, RPCSelectTextChannelArgs, RPCSelectVoiceChannelArgs, RPCSetActivityArgs, RPCSetVoiceSettingsArgs, RPCCommandSubscribePayload, RPCAcceptActivityInviteArgs, RPCActivityInviteUserArgs, RPCBraintreePopupBridgeCallbackArgs, RPCBrowserHandoffArgs, RPCCloseActivityJoinRequestArgs, RPCConnectionsCallbackArgs, RPCCreateChannelInviteArgs, RPCDeepLinkArgs, RPCGetApplicationTicketArgs, RPCGetEntitlementTicketArgs, RPCGetEntitlementsArgs, RPCGetImageArgs, RPCGetNetworkingConfigArgs, RPCGetRelationshipsArgs, RPCGetSelectedVoiceChannelArgs, RPCGetSkusArgs, RPCGiftCodeBrowserArgs, RPCGuildTemplateBrowserArgs, RPCInviteBrowserArgs, RPCNetworkingCreateTokenArgs, RPCNetworkingPeerMetricsArgs, RPCNetworkingSystemMetricsArgs, RPCOpenOverlayActivityInviteArgs, RPCOpenOverlayGuildInviteArgs, RPCOpenOverlayVoiceSettingsArgs, RPCOverlayArgs, RPCSendActivityJoinInviteArgs, RPCSetCertifiedDevicesArgs, RPCSetOverlayLockedArgs, RPCSetUserVoiceSettingsArgs, RPCSetUserVoiceSettings2Args, RPCSetVoiceSettings2Args, RPCStartPurchaseArgs, RPCValidateApplicationArgs, RPCAuthorizeResultData, RPCAuthenticateResultData, RPCGetChannelResultData, RPCGetChannelsResultData, RPCGetGuildResultData, RPCGetGuildsResultData, RPCGetUserResultData, RPCGetVoiceSettingsResultData, RPCSelectTextChannelResultData, RPCSelectVoiceChannelResultData, RPCSetActivityResultData, RPCSetVoiceSettingsResultData, RPCSubscribeResultData, RPCUnsubscribeResultData, RPCAcceptActivityInviteResultData, RPCActivityInviteUserResultData, RPCBraintreePopupBridgeCallbackResultData, RPCBrowserHandoffResultData, RPCCloseActivityJoinRequestResultData, RPCConnectionsCallbackResultData, RPCCreateChannelInviteResultData, RPCDeepLinkResultData, RPCGetApplicationTicketResultData, RPCGetEntitlementTicketResultData, RPCGetEntitlementsResultData, RPCGetImageResultData, RPCGetNetworkingConfigResultData, RPCGetRelationshipsResultData, RPCGetSelectedVoiceChannelResultData, RPCGetSkusResultData, RPCGiftCodeBrowserResultData, RPCGuildTemplateBrowserResultData, RPCInviteBrowserResultData, RPCNetworkingCreateTokenResultData, RPCNetworkingPeerMetricsResultData, RPCNetworkingSystemMetricsResultData, RPCOpenOverlayActivityInviteResultData, RPCOpenOverlayGuildInviteResultData, RPCOpenOverlayVoiceSettingsResultData, RPCOverlayResultData, RPCSendActivityJoinInviteResultData, RPCSetCertifiedDevicesResultData, RPCSetOverlayLockedResultData, RPCSetUserVoiceSettingsResultData, RPCSetUserVoiceSettings2ResultData, RPCSetVoiceSettings2ResultData, RPCStartPurchaseResultData, RPCValidateApplicationResultData, RPCMessagePayload, OAuth2Scopes, RPCOAuth2Application, APIUser, Snowflake, RPCCertifiedDevice, RPCErrorCodes } from 'discord-api-types/v10';
|
|
3
|
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
4
|
+
import { Buffer } from 'node:buffer';
|
|
5
|
+
|
|
6
|
+
declare enum Events {
|
|
7
|
+
ApplicationReady = "APPLICATION_READY",
|
|
8
|
+
Disconnected = "DISCONNECTED"
|
|
9
|
+
}
|
|
10
|
+
interface MappedRPCCommandsResultsData {
|
|
11
|
+
[RPCCommands.Authorize]: RPCAuthorizeResultData;
|
|
12
|
+
[RPCCommands.Authenticate]: RPCAuthenticateResultData;
|
|
13
|
+
[RPCCommands.GetChannel]: RPCGetChannelResultData;
|
|
14
|
+
[RPCCommands.GetChannels]: RPCGetChannelsResultData;
|
|
15
|
+
[RPCCommands.GetGuild]: RPCGetGuildResultData;
|
|
16
|
+
[RPCCommands.GetGuilds]: RPCGetGuildsResultData;
|
|
17
|
+
[RPCCommands.GetUser]: RPCGetUserResultData;
|
|
18
|
+
[RPCCommands.GetVoiceSettings]: RPCGetVoiceSettingsResultData;
|
|
19
|
+
[RPCCommands.SelectTextChannel]: RPCSelectTextChannelResultData;
|
|
20
|
+
[RPCCommands.SelectVoiceChannel]: RPCSelectVoiceChannelResultData;
|
|
21
|
+
[RPCCommands.SetActivity]: RPCSetActivityResultData;
|
|
22
|
+
[RPCCommands.SetVoiceSettings]: RPCSetVoiceSettingsResultData;
|
|
23
|
+
[RPCCommands.Subscribe]: RPCSubscribeResultData;
|
|
24
|
+
[RPCCommands.Unsubscribe]: RPCUnsubscribeResultData;
|
|
25
|
+
[RPCCommands.AcceptActivityInvite]: RPCAcceptActivityInviteResultData;
|
|
26
|
+
[RPCCommands.ActivityInviteUser]: RPCActivityInviteUserResultData;
|
|
27
|
+
[RPCCommands.BraintreePopupBridgeCallback]: RPCBraintreePopupBridgeCallbackResultData;
|
|
28
|
+
[RPCCommands.BrowserHandoff]: RPCBrowserHandoffResultData;
|
|
29
|
+
[RPCCommands.CloseActivityJoinRequest]: RPCCloseActivityJoinRequestResultData;
|
|
30
|
+
[RPCCommands.ConnectionsCallback]: RPCConnectionsCallbackResultData;
|
|
31
|
+
[RPCCommands.CreateChannelInvite]: RPCCreateChannelInviteResultData;
|
|
32
|
+
[RPCCommands.DeepLink]: RPCDeepLinkResultData;
|
|
33
|
+
[RPCCommands.GetApplicationTicket]: RPCGetApplicationTicketResultData;
|
|
34
|
+
[RPCCommands.GetEntitlementTicket]: RPCGetEntitlementTicketResultData;
|
|
35
|
+
[RPCCommands.GetEntitlements]: RPCGetEntitlementsResultData;
|
|
36
|
+
[RPCCommands.GetImage]: RPCGetImageResultData;
|
|
37
|
+
[RPCCommands.GetNetworkingConfig]: RPCGetNetworkingConfigResultData;
|
|
38
|
+
[RPCCommands.GetRelationships]: RPCGetRelationshipsResultData;
|
|
39
|
+
[RPCCommands.GetSelectedVoiceChannel]: RPCGetSelectedVoiceChannelResultData;
|
|
40
|
+
[RPCCommands.GetSkus]: RPCGetSkusResultData;
|
|
41
|
+
[RPCCommands.GiftCodeBrowser]: RPCGiftCodeBrowserResultData;
|
|
42
|
+
[RPCCommands.GuildTemplateBrowser]: RPCGuildTemplateBrowserResultData;
|
|
43
|
+
[RPCCommands.InviteBrowser]: RPCInviteBrowserResultData;
|
|
44
|
+
[RPCCommands.NetworkingCreateToken]: RPCNetworkingCreateTokenResultData;
|
|
45
|
+
[RPCCommands.NetworkingPeerMetrics]: RPCNetworkingPeerMetricsResultData;
|
|
46
|
+
[RPCCommands.NetworkingSystemMetrics]: RPCNetworkingSystemMetricsResultData;
|
|
47
|
+
[RPCCommands.OpenOverlayActivityInvite]: RPCOpenOverlayActivityInviteResultData;
|
|
48
|
+
[RPCCommands.OpenOverlayGuildInvite]: RPCOpenOverlayGuildInviteResultData;
|
|
49
|
+
[RPCCommands.OpenOverlayVoiceSettings]: RPCOpenOverlayVoiceSettingsResultData;
|
|
50
|
+
[RPCCommands.Overlay]: RPCOverlayResultData;
|
|
51
|
+
[RPCCommands.SendActivityJoinInvite]: RPCSendActivityJoinInviteResultData;
|
|
52
|
+
[RPCCommands.SetCertifiedDevices]: RPCSetCertifiedDevicesResultData;
|
|
53
|
+
[RPCCommands.SetOverlayLocked]: RPCSetOverlayLockedResultData;
|
|
54
|
+
[RPCCommands.SetUserVoiceSettings]: RPCSetUserVoiceSettingsResultData;
|
|
55
|
+
[RPCCommands.SetUserVoiceSettings2]: RPCSetUserVoiceSettings2ResultData;
|
|
56
|
+
[RPCCommands.SetVoiceSettings2]: RPCSetVoiceSettings2ResultData;
|
|
57
|
+
[RPCCommands.StartPurchase]: RPCStartPurchaseResultData;
|
|
58
|
+
[RPCCommands.ValidateApplication]: RPCValidateApplicationResultData;
|
|
59
|
+
}
|
|
60
|
+
interface MappedRPCCommandsArgs {
|
|
61
|
+
[RPCCommands.Authorize]: RPCAuthorizeArgs;
|
|
62
|
+
[RPCCommands.Authenticate]: RPCAuthenticateArgs;
|
|
63
|
+
[RPCCommands.GetChannel]: RPCGetChannelArgs;
|
|
64
|
+
[RPCCommands.GetChannels]: RPCGetChannelsArgs;
|
|
65
|
+
[RPCCommands.GetGuild]: RPCGetGuildArgs;
|
|
66
|
+
[RPCCommands.GetGuilds]: RPCGetGuildsArgs;
|
|
67
|
+
[RPCCommands.GetUser]: RPCGetUserArgs;
|
|
68
|
+
[RPCCommands.GetVoiceSettings]: RPCGetVoiceSettingsArgs;
|
|
69
|
+
[RPCCommands.SelectTextChannel]: RPCSelectTextChannelArgs;
|
|
70
|
+
[RPCCommands.SelectVoiceChannel]: RPCSelectVoiceChannelArgs;
|
|
71
|
+
[RPCCommands.SetActivity]: RPCSetActivityArgs;
|
|
72
|
+
[RPCCommands.SetVoiceSettings]: RPCSetVoiceSettingsArgs;
|
|
73
|
+
[RPCCommands.Subscribe]: RPCCommandSubscribePayload['args'];
|
|
74
|
+
[RPCCommands.Unsubscribe]: RPCCommandSubscribePayload['args'];
|
|
75
|
+
[RPCCommands.AcceptActivityInvite]: RPCAcceptActivityInviteArgs;
|
|
76
|
+
[RPCCommands.ActivityInviteUser]: RPCActivityInviteUserArgs;
|
|
77
|
+
[RPCCommands.BraintreePopupBridgeCallback]: RPCBraintreePopupBridgeCallbackArgs;
|
|
78
|
+
[RPCCommands.BrowserHandoff]: RPCBrowserHandoffArgs;
|
|
79
|
+
[RPCCommands.CloseActivityJoinRequest]: RPCCloseActivityJoinRequestArgs;
|
|
80
|
+
[RPCCommands.ConnectionsCallback]: RPCConnectionsCallbackArgs;
|
|
81
|
+
[RPCCommands.CreateChannelInvite]: RPCCreateChannelInviteArgs;
|
|
82
|
+
[RPCCommands.DeepLink]: RPCDeepLinkArgs;
|
|
83
|
+
[RPCCommands.GetApplicationTicket]: RPCGetApplicationTicketArgs;
|
|
84
|
+
[RPCCommands.GetEntitlementTicket]: RPCGetEntitlementTicketArgs;
|
|
85
|
+
[RPCCommands.GetEntitlements]: RPCGetEntitlementsArgs;
|
|
86
|
+
[RPCCommands.GetImage]: RPCGetImageArgs;
|
|
87
|
+
[RPCCommands.GetNetworkingConfig]: RPCGetNetworkingConfigArgs;
|
|
88
|
+
[RPCCommands.GetRelationships]: RPCGetRelationshipsArgs;
|
|
89
|
+
[RPCCommands.GetSelectedVoiceChannel]: RPCGetSelectedVoiceChannelArgs;
|
|
90
|
+
[RPCCommands.GetSkus]: RPCGetSkusArgs;
|
|
91
|
+
[RPCCommands.GiftCodeBrowser]: RPCGiftCodeBrowserArgs;
|
|
92
|
+
[RPCCommands.GuildTemplateBrowser]: RPCGuildTemplateBrowserArgs;
|
|
93
|
+
[RPCCommands.InviteBrowser]: RPCInviteBrowserArgs;
|
|
94
|
+
[RPCCommands.NetworkingCreateToken]: RPCNetworkingCreateTokenArgs;
|
|
95
|
+
[RPCCommands.NetworkingPeerMetrics]: RPCNetworkingPeerMetricsArgs;
|
|
96
|
+
[RPCCommands.NetworkingSystemMetrics]: RPCNetworkingSystemMetricsArgs;
|
|
97
|
+
[RPCCommands.OpenOverlayActivityInvite]: RPCOpenOverlayActivityInviteArgs;
|
|
98
|
+
[RPCCommands.OpenOverlayGuildInvite]: RPCOpenOverlayGuildInviteArgs;
|
|
99
|
+
[RPCCommands.OpenOverlayVoiceSettings]: RPCOpenOverlayVoiceSettingsArgs;
|
|
100
|
+
[RPCCommands.Overlay]: RPCOverlayArgs;
|
|
101
|
+
[RPCCommands.SendActivityJoinInvite]: RPCSendActivityJoinInviteArgs;
|
|
102
|
+
[RPCCommands.SetCertifiedDevices]: RPCSetCertifiedDevicesArgs;
|
|
103
|
+
[RPCCommands.SetOverlayLocked]: RPCSetOverlayLockedArgs;
|
|
104
|
+
[RPCCommands.SetUserVoiceSettings]: RPCSetUserVoiceSettingsArgs;
|
|
105
|
+
[RPCCommands.SetUserVoiceSettings2]: RPCSetUserVoiceSettings2Args;
|
|
106
|
+
[RPCCommands.SetVoiceSettings2]: RPCSetVoiceSettings2Args;
|
|
107
|
+
[RPCCommands.StartPurchase]: RPCStartPurchaseArgs;
|
|
108
|
+
[RPCCommands.ValidateApplication]: RPCValidateApplicationArgs;
|
|
109
|
+
}
|
|
110
|
+
type RPCCallableCommands = Exclude<RPCCommands, RPCCommands.Dispatch>;
|
|
111
|
+
interface MappedRPCSubscribeEventsArgs {
|
|
112
|
+
[RPCEvents.ActivityInvite]: RPCSubscribeActivityInviteArgs;
|
|
113
|
+
[RPCEvents.ActivityJoin]: RPCSubscribeActivityJoinArgs;
|
|
114
|
+
[RPCEvents.ActivityJoinRequest]: RPCSubscribeActivityJoinRequestArgs;
|
|
115
|
+
[RPCEvents.ActivitySpectate]: RPCSubscribeActivitySpectateArgs;
|
|
116
|
+
[RPCEvents.ChannelCreate]: RPCSubscribeChannelCreateArgs;
|
|
117
|
+
[RPCEvents.CurrentUserUpdate]: RPCSubscribeCurrentUserUpdateArgs;
|
|
118
|
+
[RPCEvents.EntitlementCreate]: RPCSubscribeEntitlementCreateArgs;
|
|
119
|
+
[RPCEvents.EntitlementDelete]: RPCSubscribeEntitlementDeleteArgs;
|
|
120
|
+
[RPCEvents.GameJoin]: RPCSubscribeGameJoinArgs;
|
|
121
|
+
[RPCEvents.GameSpectate]: RPCSubscribeGameSpectateArgs;
|
|
122
|
+
[RPCEvents.GuildCreate]: RPCSubscribeGuildCreateArgs;
|
|
123
|
+
[RPCEvents.GuildStatus]: RPCSubscribeGuildStatusArgs;
|
|
124
|
+
[RPCEvents.MessageCreate]: RPCSubscribeMessageCreateArgs;
|
|
125
|
+
[RPCEvents.MessageDelete]: RPCSubscribeMessageDeleteArgs;
|
|
126
|
+
[RPCEvents.MessageUpdate]: RPCSubscribeMessageUpdateArgs;
|
|
127
|
+
[RPCEvents.NotificationCreate]: RPCSubscribeNotificationCreateArgs;
|
|
128
|
+
[RPCEvents.Overlay]: RPCSubscribeOverlayArgs;
|
|
129
|
+
[RPCEvents.OverlayUpdate]: RPCSubscribeOverlayUpdateArgs;
|
|
130
|
+
[RPCEvents.RelationshipUpdate]: RPCSubscribeRelationshipUpdateArgs;
|
|
131
|
+
[RPCEvents.SpeakingStart]: RPCSubscribeSpeakingStartArgs;
|
|
132
|
+
[RPCEvents.SpeakingStop]: RPCSubscribeSpeakingStopArgs;
|
|
133
|
+
[RPCEvents.VoiceChannelSelect]: RPCSubscribeVoiceChannelSelectArgs;
|
|
134
|
+
[RPCEvents.VoiceConnectionStatus]: RPCSubscribeVoiceConnectionStatusArgs;
|
|
135
|
+
[RPCEvents.VoiceSettingsUpdate]: RPCSubscribeVoiceSettingsUpdateArgs;
|
|
136
|
+
[RPCEvents.VoiceSettingsUpdate2]: RPCSubscribeVoiceSettingsUpdate2Args;
|
|
137
|
+
[RPCEvents.VoiceStateCreate]: RPCSubscribeVoiceStateCreateArgs;
|
|
138
|
+
[RPCEvents.VoiceStateDelete]: RPCSubscribeVoiceStateDeleteArgs;
|
|
139
|
+
[RPCEvents.VoiceStateUpdate]: RPCSubscribeVoiceStateUpdateArgs;
|
|
140
|
+
}
|
|
141
|
+
interface MappedRPCEventsDispatchData {
|
|
142
|
+
[RPCEvents.ActivityInvite]: [RPCActivityInviteDispatchData];
|
|
143
|
+
[RPCEvents.ActivityJoin]: [RPCActivityJoinDispatchData];
|
|
144
|
+
[RPCEvents.ActivityJoinRequest]: [RPCActivityJoinRequestDispatchData];
|
|
145
|
+
[RPCEvents.ActivitySpectate]: [RPCActivitySpectateDispatchData];
|
|
146
|
+
[RPCEvents.ChannelCreate]: [RPCChannelCreateDispatchData];
|
|
147
|
+
[RPCEvents.CurrentUserUpdate]: [RPCCurrentUserUpdateDispatchData];
|
|
148
|
+
[RPCEvents.EntitlementCreate]: [RPCEntitlementCreateDispatchData];
|
|
149
|
+
[RPCEvents.EntitlementDelete]: [RPCEntitlementDeleteDispatchData];
|
|
150
|
+
[RPCEvents.Error]: [RPCErrorDispatchData];
|
|
151
|
+
[RPCEvents.GameJoin]: [RPCGameJoinDispatchData];
|
|
152
|
+
[RPCEvents.GameSpectate]: [RPCGameSpectateDispatchData];
|
|
153
|
+
[RPCEvents.GuildCreate]: [RPCGuildCreateDispatchData];
|
|
154
|
+
[RPCEvents.GuildStatus]: [RPCGuildStatusDispatchData];
|
|
155
|
+
[RPCEvents.MessageCreate]: [RPCMessageCreateDispatchData];
|
|
156
|
+
[RPCEvents.MessageDelete]: [RPCMessageDeleteDispatchData];
|
|
157
|
+
[RPCEvents.MessageUpdate]: [RPCMessageUpdateDispatchData];
|
|
158
|
+
[RPCEvents.NotificationCreate]: [RPCNotificationCreateDispatchData];
|
|
159
|
+
[RPCEvents.Overlay]: [RPCOverlayDispatchData];
|
|
160
|
+
[RPCEvents.OverlayUpdate]: [RPCOverlayUpdateDispatchData];
|
|
161
|
+
[RPCEvents.Ready]: [RPCReadyDispatchData];
|
|
162
|
+
[RPCEvents.RelationshipUpdate]: [RPCRelationshipUpdateDispatchData];
|
|
163
|
+
[RPCEvents.SpeakingStart]: [RPCSpeakingStartDispatchData];
|
|
164
|
+
[RPCEvents.SpeakingStop]: [RPCSpeakingStopDispatchData];
|
|
165
|
+
[RPCEvents.VoiceChannelSelect]: [RPCVoiceChannelSelectDispatchData];
|
|
166
|
+
[RPCEvents.VoiceConnectionStatus]: [RPCVoiceConnectionStatusDispatchData];
|
|
167
|
+
[RPCEvents.VoiceSettingsUpdate]: [RPCVoiceSettingsUpdateDispatchData];
|
|
168
|
+
[RPCEvents.VoiceSettingsUpdate2]: [RPCVoiceSettingsUpdate2DispatchData];
|
|
169
|
+
[RPCEvents.VoiceStateCreate]: [RPCVoiceStateCreateDispatchData];
|
|
170
|
+
[RPCEvents.VoiceStateDelete]: [RPCVoiceStateDeleteDispatchData];
|
|
171
|
+
[RPCEvents.VoiceStateUpdate]: [RPCVoiceStateUpdateDispatchData];
|
|
172
|
+
}
|
|
173
|
+
interface MappedEvents {
|
|
174
|
+
[Events.ApplicationReady]: [];
|
|
175
|
+
[Events.Disconnected]: [];
|
|
176
|
+
}
|
|
177
|
+
type EventAndArgsParameters<Evt extends RPCEvents> = Evt extends RPCEvents.Error | RPCEvents.Ready ? never : [Evt, MappedRPCSubscribeEventsArgs[Exclude<Evt, RPCEvents.Error | RPCEvents.Ready>], RequestOptions?];
|
|
178
|
+
|
|
179
|
+
declare enum OPCodes {
|
|
180
|
+
Handshake = 0,
|
|
181
|
+
Frame = 1,
|
|
182
|
+
Close = 2,
|
|
183
|
+
Ping = 3,
|
|
184
|
+
Pong = 4
|
|
185
|
+
}
|
|
186
|
+
interface HandshakePayload {
|
|
187
|
+
client_id: string;
|
|
188
|
+
v: number;
|
|
189
|
+
}
|
|
190
|
+
declare function encode(op: number, data: HandshakePayload | Record<string, never> | RPCMessagePayload | string): Buffer<ArrayBuffer>;
|
|
191
|
+
declare class IPCTransport extends AsyncEventEmitter {
|
|
192
|
+
readonly client: RPCClient;
|
|
193
|
+
private socket;
|
|
194
|
+
private readonly working;
|
|
195
|
+
constructor(client: RPCClient);
|
|
196
|
+
connect(): Promise<void>;
|
|
197
|
+
private decode;
|
|
198
|
+
onClose(data: unknown): void;
|
|
199
|
+
onError(error: unknown): void;
|
|
200
|
+
send(data: string, op: OPCodes.Ping): void;
|
|
201
|
+
send(data: RPCMessagePayload, op?: OPCodes.Frame | OPCodes.Pong): void;
|
|
202
|
+
send(data: Record<string, never>, op: OPCodes.Close): void;
|
|
203
|
+
close(options?: RequestOptions): Promise<unknown>;
|
|
204
|
+
/**
|
|
205
|
+
* Manual ping method
|
|
206
|
+
*/
|
|
207
|
+
ping(): void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface RPCClientOptions {
|
|
211
|
+
/**
|
|
212
|
+
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant
|
|
213
|
+
*
|
|
214
|
+
* for authorization requests
|
|
215
|
+
*/
|
|
216
|
+
prompt?: 'consent' | 'none';
|
|
217
|
+
/**
|
|
218
|
+
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant
|
|
219
|
+
*
|
|
220
|
+
* for authorization requests
|
|
221
|
+
*/
|
|
222
|
+
redirectUri?: string;
|
|
223
|
+
/**
|
|
224
|
+
* An array of scopes
|
|
225
|
+
*/
|
|
226
|
+
scopes?: OAuth2Scopes[];
|
|
227
|
+
/**
|
|
228
|
+
* the client username
|
|
229
|
+
*/
|
|
230
|
+
username?: string;
|
|
231
|
+
}
|
|
232
|
+
interface RPCLoginOptions {
|
|
233
|
+
/**
|
|
234
|
+
* Access Token
|
|
235
|
+
*/
|
|
236
|
+
accessToken?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Client id
|
|
239
|
+
*/
|
|
240
|
+
clientId: string;
|
|
241
|
+
/**
|
|
242
|
+
* Client Secret
|
|
243
|
+
*/
|
|
244
|
+
clientSecret?: string;
|
|
245
|
+
}
|
|
246
|
+
interface RequestOptions {
|
|
247
|
+
signal?: AbortSignal;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The client for interacting with Discord RPC
|
|
251
|
+
*/
|
|
252
|
+
declare class RPCClient extends AsyncEventEmitter<MappedRPCEventsDispatchData> {
|
|
253
|
+
#private;
|
|
254
|
+
options: RPCClientOptions;
|
|
255
|
+
accessToken: string;
|
|
256
|
+
clientId: string;
|
|
257
|
+
clientSecret: string;
|
|
258
|
+
readyTimestamp: number | null;
|
|
259
|
+
application: RPCOAuth2Application | null;
|
|
260
|
+
user: APIUser | null;
|
|
261
|
+
/**
|
|
262
|
+
* The transport for the IPC
|
|
263
|
+
*/
|
|
264
|
+
transport: IPCTransport;
|
|
265
|
+
constructor(options?: RPCClientOptions);
|
|
266
|
+
/**
|
|
267
|
+
* Returns the Date for when the client became ready
|
|
268
|
+
*/
|
|
269
|
+
get readyAt(): Date | null;
|
|
270
|
+
/**
|
|
271
|
+
* Returns true if the client is currently ready
|
|
272
|
+
*/
|
|
273
|
+
get ready(): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Search and connect to RPC
|
|
276
|
+
*/
|
|
277
|
+
connect(options?: RequestOptions): Promise<RPCClient>;
|
|
278
|
+
/**
|
|
279
|
+
* Performs authentication flow. Automatically calls Client#connect if needed.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* logging in with a client id and secret
|
|
283
|
+
* ```ts
|
|
284
|
+
* client.login({ clientId: '1234567', clientSecret: 'abcdef123' });
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
login({ clientId, clientSecret, accessToken }: RPCLoginOptions, options?: RequestOptions): Promise<RPCClient>;
|
|
288
|
+
/**
|
|
289
|
+
* Request
|
|
290
|
+
*
|
|
291
|
+
* @param cmd - Command
|
|
292
|
+
* @param args - Arguments
|
|
293
|
+
* @param evt - Event
|
|
294
|
+
*/
|
|
295
|
+
request<Cmd extends RPCCallableCommands = RPCCallableCommands>(cmd: Cmd, args?: MappedRPCCommandsArgs[Cmd], options?: RequestOptions & {
|
|
296
|
+
evt?: RPCEvents;
|
|
297
|
+
}): Promise<MappedRPCCommandsResultsData[Cmd]>;
|
|
298
|
+
request(cmd: RPCCommands.Subscribe | RPCCommands.Unsubscribe, args: RPCCommandSubscribePayload['args'], options: RequestOptions & {
|
|
299
|
+
evt: RPCEvents;
|
|
300
|
+
}): Promise<RPCSubscribeResultData | RPCUnsubscribeResultData>;
|
|
301
|
+
/**
|
|
302
|
+
* Authorize
|
|
303
|
+
*
|
|
304
|
+
* @param args - authorize args
|
|
305
|
+
*/
|
|
306
|
+
private authorize;
|
|
307
|
+
/**
|
|
308
|
+
* Authenticate
|
|
309
|
+
*
|
|
310
|
+
* @param accessToken - access token
|
|
311
|
+
*/
|
|
312
|
+
authenticate(accessToken: string, options?: RequestOptions): Promise<this>;
|
|
313
|
+
/**
|
|
314
|
+
* Fetch a guild
|
|
315
|
+
*
|
|
316
|
+
* @param id - Guild id
|
|
317
|
+
* @param timeout - Timeout request
|
|
318
|
+
*/
|
|
319
|
+
getGuild(id: Snowflake, timeout: number, options?: RequestOptions): Promise<RPCGetGuildResultData>;
|
|
320
|
+
/**
|
|
321
|
+
* Fetch all guilds
|
|
322
|
+
*
|
|
323
|
+
* @param timeout - Timeout request
|
|
324
|
+
*/
|
|
325
|
+
getGuilds(timeout: number, options?: RequestOptions): Promise<RPCGetGuildsResultData>;
|
|
326
|
+
/**
|
|
327
|
+
* Get a channel
|
|
328
|
+
*
|
|
329
|
+
* @param id - Channel id
|
|
330
|
+
*/
|
|
331
|
+
getChannel(id: Snowflake, options?: RequestOptions): Promise<RPCGetChannelResultData>;
|
|
332
|
+
/**
|
|
333
|
+
* Get all channels
|
|
334
|
+
*
|
|
335
|
+
* @param id - Guild id
|
|
336
|
+
*/
|
|
337
|
+
getChannels(id: Snowflake, options?: RequestOptions): Promise<RPCGetChannelsResultData['channels']>;
|
|
338
|
+
/**
|
|
339
|
+
* Create channel invite
|
|
340
|
+
*
|
|
341
|
+
* @param id - Channel id
|
|
342
|
+
*/
|
|
343
|
+
createChannelInvite(id: Snowflake, options?: RequestOptions): Promise<RPCCreateChannelInviteResultData>;
|
|
344
|
+
/**
|
|
345
|
+
* Tell discord which devices are certified
|
|
346
|
+
*
|
|
347
|
+
* @param devices - Certified devices to send to discord
|
|
348
|
+
*/
|
|
349
|
+
setCertifiedDevices(devices: RPCCertifiedDevice[], options?: RequestOptions): Promise<RPCSetCertifiedDevicesResultData>;
|
|
350
|
+
/**
|
|
351
|
+
* Set the voice settings for a user, by id
|
|
352
|
+
*
|
|
353
|
+
* @param id - Id of the user to set
|
|
354
|
+
* @param settings - Settings to set
|
|
355
|
+
*/
|
|
356
|
+
setUserVoiceSettings(id: Snowflake, settings: Omit<Partial<RPCSetUserVoiceSettingsArgs>, 'user_id'>, options?: RequestOptions): Promise<RPCSetUserVoiceSettingsResultData>;
|
|
357
|
+
/**
|
|
358
|
+
* Move the user to a voice channel
|
|
359
|
+
*
|
|
360
|
+
* @param id - Id of the voice channel
|
|
361
|
+
* @param args - select voice channel args
|
|
362
|
+
* @param options - request options
|
|
363
|
+
*/
|
|
364
|
+
selectVoiceChannel(id: Snowflake, args?: Omit<RPCSelectVoiceChannelArgs, 'channel_id'>, options?: RequestOptions): Promise<RPCSelectVoiceChannelResultData>;
|
|
365
|
+
/**
|
|
366
|
+
* Move the user to a text channel
|
|
367
|
+
*
|
|
368
|
+
* @param id - Id of the text channel
|
|
369
|
+
* @param args - select text channel args
|
|
370
|
+
* @param options - request options
|
|
371
|
+
*/
|
|
372
|
+
selectTextChannel(id: Snowflake, args?: Omit<RPCSelectTextChannelArgs, 'channel_id'>, options?: RequestOptions): Promise<RPCSelectTextChannelResultData>;
|
|
373
|
+
/**
|
|
374
|
+
* Get current voice settings
|
|
375
|
+
*
|
|
376
|
+
*/
|
|
377
|
+
getVoiceSettings(options?: RequestOptions): Promise<RPCGetVoiceSettingsResultData>;
|
|
378
|
+
/**
|
|
379
|
+
* Set current voice settings, overriding the current settings until this session disconnects.
|
|
380
|
+
* This also locks the settings for any other rpc sessions which may be connected.
|
|
381
|
+
*
|
|
382
|
+
* @param args - Settings
|
|
383
|
+
*/
|
|
384
|
+
setVoiceSettings(args: RPCSetVoiceSettingsArgs, options?: RequestOptions): Promise<unknown>;
|
|
385
|
+
/**
|
|
386
|
+
* Sets the presence for the logged in user.
|
|
387
|
+
*
|
|
388
|
+
* @param activity - The rich presence to pass.
|
|
389
|
+
* @param pid - The application's process ID. Defaults to the executing process' PID.
|
|
390
|
+
* @remarks
|
|
391
|
+
* Clients may only update their activity 5 times per 20 seconds.
|
|
392
|
+
*/
|
|
393
|
+
setActivity(activity?: RPCSetActivityArgs['activity'], pid?: number | null, options?: RequestOptions): Promise<unknown>;
|
|
394
|
+
/**
|
|
395
|
+
* Clears the currently set presence, if any. This will hide the "Playing X" message
|
|
396
|
+
* displayed below the user's name.
|
|
397
|
+
*
|
|
398
|
+
* @param pid - The application's process ID. Defaults to the executing process' PID.
|
|
399
|
+
*/
|
|
400
|
+
clearActivity(pid?: number | null, options?: RequestOptions): Promise<unknown>;
|
|
401
|
+
/**
|
|
402
|
+
* Invite a user to join the game the RPC user is currently playing
|
|
403
|
+
*
|
|
404
|
+
* @param userId - The id of the user to invite
|
|
405
|
+
*/
|
|
406
|
+
sendJoinInvite(userId: Snowflake, options?: RequestOptions): Promise<unknown>;
|
|
407
|
+
/**
|
|
408
|
+
* Reject a join request from a user
|
|
409
|
+
*
|
|
410
|
+
* @param userId - The id of the user whose request you wish to reject
|
|
411
|
+
*/
|
|
412
|
+
closeJoinRequest(userId: Snowflake, options?: RequestOptions): Promise<unknown>;
|
|
413
|
+
/**
|
|
414
|
+
* requires `relationships.read` scope
|
|
415
|
+
*/
|
|
416
|
+
getRelationships(options?: RequestOptions): Promise<discord_api_types_v10.RPCGetRelationshipsResultData>;
|
|
417
|
+
/**
|
|
418
|
+
* Fetches a user
|
|
419
|
+
*/
|
|
420
|
+
getUser(id: Snowflake, options?: RequestOptions): Promise<APIUser>;
|
|
421
|
+
/**
|
|
422
|
+
* Fetches a user's profile picture
|
|
423
|
+
*/
|
|
424
|
+
getImage({ id, format, size }: Omit<RPCGetImageArgs, 'type'>, options?: RequestOptions): Promise<string>;
|
|
425
|
+
/**
|
|
426
|
+
* Subscribe to an event
|
|
427
|
+
*
|
|
428
|
+
* @param event - Name of event e.g. `MESSAGE_CREATE`
|
|
429
|
+
* @param args - Args for event e.g. `{ channel_id: '1234' }`
|
|
430
|
+
*/
|
|
431
|
+
subscribe<Evt extends RPCEvents>(...[event, args, options]: EventAndArgsParameters<Evt>): Promise<{
|
|
432
|
+
unsubscribe(): Promise<RPCUnsubscribeResultData>;
|
|
433
|
+
}>;
|
|
434
|
+
/**
|
|
435
|
+
* Unsubscribe from an event
|
|
436
|
+
*
|
|
437
|
+
* @param event - Name of event e.g. `MESSAGE_CREATE`
|
|
438
|
+
* @param args - Args for event e.g. `{ channel_id: '1234' }`
|
|
439
|
+
*/
|
|
440
|
+
unsubscribe<Evt extends RPCEvents>(...[event, args, options]: EventAndArgsParameters<Evt>): Promise<{
|
|
441
|
+
subscribe(): Promise<RPCSubscribeResultData>;
|
|
442
|
+
}>;
|
|
443
|
+
/**
|
|
444
|
+
* Destroy the client
|
|
445
|
+
*/
|
|
446
|
+
destroy(): Promise<void>;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
declare class RPCEventError extends Error {
|
|
450
|
+
code?: RPCErrorCodes;
|
|
451
|
+
data?: RPCErrorDispatchData;
|
|
452
|
+
constructor(data: RPCErrorDispatchData | string);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
declare const register: () => Promise<boolean | unknown>;
|
|
456
|
+
declare function getPid(): number | null;
|
|
457
|
+
declare function isValidTimestamp(timestamp: number): boolean;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rpc#readme | @discordjs/rpc} version
|
|
461
|
+
* that you are currently using.
|
|
462
|
+
*/
|
|
463
|
+
declare const version: string;
|
|
464
|
+
|
|
465
|
+
export { type EventAndArgsParameters, Events, IPCTransport, type MappedEvents, type MappedRPCCommandsArgs, type MappedRPCCommandsResultsData, type MappedRPCEventsDispatchData, type MappedRPCSubscribeEventsArgs, type RPCCallableCommands, RPCClient, type RPCClientOptions, RPCEventError, type RPCLoginOptions, type RequestOptions, encode, getPid, isValidTimestamp, register, version };
|