snowtransfer 0.18.0 → 0.18.1

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/Constants.d.ts +59 -0
  3. package/dist/Constants.js +123 -0
  4. package/dist/Endpoints.d.ts +120 -0
  5. package/dist/Endpoints.js +121 -0
  6. package/dist/RequestHandler.d.ts +258 -0
  7. package/dist/RequestHandler.js +629 -0
  8. package/dist/SnowTransfer.d.ts +70 -0
  9. package/dist/SnowTransfer.js +105 -0
  10. package/dist/StateMachine.d.ts +89 -0
  11. package/dist/StateMachine.js +208 -0
  12. package/dist/StateMachineGraph.d.ts +3 -0
  13. package/dist/StateMachineGraph.js +23 -0
  14. package/dist/Types.d.ts +76 -0
  15. package/dist/Types.js +2 -0
  16. package/dist/index.d.ts +25 -718
  17. package/dist/index.js +63 -44
  18. package/dist/methods/Assets.d.ts +290 -0
  19. package/dist/methods/Assets.js +326 -0
  20. package/dist/methods/AuditLog.d.ts +40 -0
  21. package/dist/methods/AuditLog.js +44 -0
  22. package/dist/methods/AutoModeration.d.ts +122 -0
  23. package/dist/methods/AutoModeration.js +135 -0
  24. package/dist/methods/Bot.d.ts +65 -0
  25. package/dist/methods/Bot.js +75 -0
  26. package/dist/methods/Channel.d.ts +866 -0
  27. package/dist/methods/Channel.js +982 -0
  28. package/dist/methods/Entitlements.d.ts +87 -0
  29. package/dist/methods/Entitlements.js +99 -0
  30. package/dist/methods/Guild.d.ts +722 -0
  31. package/dist/methods/Guild.js +785 -0
  32. package/dist/methods/GuildScheduledEvent.d.ts +138 -0
  33. package/dist/methods/GuildScheduledEvent.js +155 -0
  34. package/dist/methods/GuildTemplate.d.ts +110 -0
  35. package/dist/methods/GuildTemplate.js +124 -0
  36. package/dist/methods/Interaction.d.ts +339 -0
  37. package/dist/methods/Interaction.js +359 -0
  38. package/dist/methods/Invite.d.ts +81 -0
  39. package/dist/methods/Invite.js +107 -0
  40. package/dist/methods/Sku.d.ts +58 -0
  41. package/dist/methods/Sku.js +66 -0
  42. package/dist/methods/StageInstance.d.ts +86 -0
  43. package/dist/methods/StageInstance.js +97 -0
  44. package/dist/methods/User.d.ts +167 -0
  45. package/dist/methods/User.js +184 -0
  46. package/dist/methods/Voice.d.ts +44 -0
  47. package/dist/methods/Voice.js +52 -0
  48. package/dist/methods/Webhook.d.ts +265 -0
  49. package/dist/methods/Webhook.js +256 -0
  50. package/dist/tokenless.d.ts +19 -0
  51. package/dist/tokenless.js +31 -0
  52. package/package.json +9 -9
  53. package/dist/index.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import type { RequestHandler } from "../RequestHandler";
2
+ import type { RESTDeleteAPIStageInstanceResult, RESTGetAPIStageInstanceResult, RESTPatchAPIStageInstanceJSONBody, RESTPatchAPIStageInstanceResult, RESTPostAPIStageInstanceJSONBody, RESTPostAPIStageInstanceResult } from "discord-api-types/v10";
3
+ /**
4
+ * Methods for interacting with Stage instances
5
+ * @since 0.3.0
6
+ */
7
+ declare class StageInstanceMethods {
8
+ readonly requestHandler: RequestHandler;
9
+ /**
10
+ * Create a new Stage Instance Method Handler
11
+ *
12
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
13
+ *
14
+ * You can access the methods listed via `client.stageInstance.method`, where `client` is an initialized SnowTransfer instance
15
+ * @param requestHandler request handler that calls the rest api
16
+ */
17
+ constructor(requestHandler: RequestHandler);
18
+ /**
19
+ * Creates a new stage instance associated to a stage channel
20
+ * @since 0.3.0
21
+ * @param data The options for creating a stage instance
22
+ * @param reason Reason for creating the stage instance
23
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
24
+ *
25
+ * | Permissions needed | Condition |
26
+ * |--------------------|-----------|
27
+ * | MANAGE_CHANNELS | always |
28
+ * | MUTE_MEMBERS | always |
29
+ * | MOVE_MEMBERS | always |
30
+ *
31
+ * @example
32
+ * // Create a new stage instance for channel id and the topic "This My House"
33
+ * const client = new SnowTransfer("TOKEN")
34
+ * const instance = await client.stageInstance.createStageInstance({ channel_id: "channel id", topic: "This My House" })
35
+ */
36
+ createStageInstance(data: RESTPostAPIStageInstanceJSONBody, reason?: string): Promise<RESTPostAPIStageInstanceResult>;
37
+ /**
38
+ * Gets the stage instance associated to a stage channel if it exists
39
+ * @since 0.3.0
40
+ * @param channelId Id of the stage channel
41
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
42
+ *
43
+ * @example
44
+ * const client = new SnowTransfer("TOKEN")
45
+ * const instance = await client.stageInstance.getStageInstance("channel id")
46
+ */
47
+ getStageInstance(channelId: string): Promise<RESTGetAPIStageInstanceResult>;
48
+ /**
49
+ * Updates an existing stage instance
50
+ * @since 0.3.0
51
+ * @param channelId Id of the stage channel
52
+ * @param data The new data to send
53
+ * @param reason Reason for editing the stage instance
54
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
55
+ *
56
+ * | Permissions needed | Condition |
57
+ * |--------------------|-----------|
58
+ * | MANAGE_CHANNELS | always |
59
+ * | MUTE_MEMBERS | always |
60
+ * | MOVE_MEMBERS | always |
61
+ *
62
+ * @example
63
+ * const client = new SnowTransfer("TOKEN")
64
+ * const instance = await client.stageInstance.editStageInstance("channel id", { topic: "This my city, this my town" })
65
+ */
66
+ editStageInstance(channelId: string, data: RESTPatchAPIStageInstanceJSONBody, reason?: string): Promise<RESTPatchAPIStageInstanceResult>;
67
+ /**
68
+ * Delete an existing stage instance
69
+ * @since 0.3.0
70
+ * @param channelId Id of the stage channel
71
+ * @param reason Reason for deleting the stage instance
72
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
73
+ *
74
+ * | Permissions needed | Condition |
75
+ * |--------------------|-----------|
76
+ * | MANAGE_CHANNELS | always |
77
+ * | MUTE_MEMBERS | always |
78
+ * | MOVE_MEMBERS | always |
79
+ *
80
+ * @example
81
+ * const client = new SnowTransfer("TOKEN")
82
+ * client.stageInstance.deleteStageInstance("channel id", "They already know who's house this is")
83
+ */
84
+ deleteStageInstance(channelId: string, reason?: string): Promise<RESTDeleteAPIStageInstanceResult>;
85
+ }
86
+ export = StageInstanceMethods;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ const Endpoints = require("../Endpoints");
3
+ const Constants = require("../Constants");
4
+ /**
5
+ * Methods for interacting with Stage instances
6
+ * @since 0.3.0
7
+ */
8
+ class StageInstanceMethods {
9
+ requestHandler;
10
+ /**
11
+ * Create a new Stage Instance Method Handler
12
+ *
13
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
14
+ *
15
+ * You can access the methods listed via `client.stageInstance.method`, where `client` is an initialized SnowTransfer instance
16
+ * @param requestHandler request handler that calls the rest api
17
+ */
18
+ constructor(requestHandler) {
19
+ this.requestHandler = requestHandler;
20
+ }
21
+ /**
22
+ * Creates a new stage instance associated to a stage channel
23
+ * @since 0.3.0
24
+ * @param data The options for creating a stage instance
25
+ * @param reason Reason for creating the stage instance
26
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
27
+ *
28
+ * | Permissions needed | Condition |
29
+ * |--------------------|-----------|
30
+ * | MANAGE_CHANNELS | always |
31
+ * | MUTE_MEMBERS | always |
32
+ * | MOVE_MEMBERS | always |
33
+ *
34
+ * @example
35
+ * // Create a new stage instance for channel id and the topic "This My House"
36
+ * const client = new SnowTransfer("TOKEN")
37
+ * const instance = await client.stageInstance.createStageInstance({ channel_id: "channel id", topic: "This My House" })
38
+ */
39
+ async createStageInstance(data, reason) {
40
+ return this.requestHandler.request(Endpoints.STAGE_INSTANCES, {}, "post", "json", data, Constants.reasonHeader(reason));
41
+ }
42
+ /**
43
+ * Gets the stage instance associated to a stage channel if it exists
44
+ * @since 0.3.0
45
+ * @param channelId Id of the stage channel
46
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
47
+ *
48
+ * @example
49
+ * const client = new SnowTransfer("TOKEN")
50
+ * const instance = await client.stageInstance.getStageInstance("channel id")
51
+ */
52
+ async getStageInstance(channelId) {
53
+ return this.requestHandler.request(Endpoints.STAGE_INSTANCE_CHANNEL(channelId), {}, "get", "json");
54
+ }
55
+ /**
56
+ * Updates an existing stage instance
57
+ * @since 0.3.0
58
+ * @param channelId Id of the stage channel
59
+ * @param data The new data to send
60
+ * @param reason Reason for editing the stage instance
61
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
62
+ *
63
+ * | Permissions needed | Condition |
64
+ * |--------------------|-----------|
65
+ * | MANAGE_CHANNELS | always |
66
+ * | MUTE_MEMBERS | always |
67
+ * | MOVE_MEMBERS | always |
68
+ *
69
+ * @example
70
+ * const client = new SnowTransfer("TOKEN")
71
+ * const instance = await client.stageInstance.editStageInstance("channel id", { topic: "This my city, this my town" })
72
+ */
73
+ async editStageInstance(channelId, data, reason) {
74
+ return this.requestHandler.request(Endpoints.STAGE_INSTANCE_CHANNEL(channelId), {}, "patch", "json", data, Constants.reasonHeader(reason));
75
+ }
76
+ /**
77
+ * Delete an existing stage instance
78
+ * @since 0.3.0
79
+ * @param channelId Id of the stage channel
80
+ * @param reason Reason for deleting the stage instance
81
+ * @returns a [stage instance](https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure) object
82
+ *
83
+ * | Permissions needed | Condition |
84
+ * |--------------------|-----------|
85
+ * | MANAGE_CHANNELS | always |
86
+ * | MUTE_MEMBERS | always |
87
+ * | MOVE_MEMBERS | always |
88
+ *
89
+ * @example
90
+ * const client = new SnowTransfer("TOKEN")
91
+ * client.stageInstance.deleteStageInstance("channel id", "They already know who's house this is")
92
+ */
93
+ async deleteStageInstance(channelId, reason) {
94
+ return this.requestHandler.request(Endpoints.STAGE_INSTANCE_CHANNEL(channelId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
95
+ }
96
+ }
97
+ module.exports = StageInstanceMethods;
@@ -0,0 +1,167 @@
1
+ import type { RequestHandler } from "../RequestHandler";
2
+ import type { RESTDeleteAPICurrentUserGuildResult, RESTGetAPICurrentUserApplicationRoleConnectionResult, RESTGetAPICurrentUserConnectionsResult, RESTGetAPICurrentUserGuildsQuery, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserResult, RESTGetAPIUserResult, RESTPatchAPICurrentUserJSONBody, RESTPatchAPICurrentUserResult, RESTPostAPICurrentUserCreateDMChannelResult, RESTPutAPICurrentUserApplicationRoleConnectionJSONBody, RESTPutAPICurrentUserApplicationRoleConnectionResult } from "discord-api-types/v10";
3
+ /**
4
+ * Methods for interacting with users
5
+ * @since 0.1.0
6
+ */
7
+ declare class UserMethods {
8
+ readonly requestHandler: RequestHandler;
9
+ /**
10
+ * Create a new User Method handler
11
+ *
12
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
13
+ *
14
+ * You can access the methods listed via `client.user.method`, where `client` is an initialized SnowTransfer instance
15
+ * @param requestHandler
16
+ */
17
+ constructor(requestHandler: RequestHandler);
18
+ /**
19
+ * Get information about the CurrentUser
20
+ * @since 0.1.0
21
+ * @returns A [user object](https://discord.com/developers/docs/resources/user#user-object)
22
+ *
23
+ * | OAUTH2 Scopes | Condition |
24
+ * |---------------|---------------|
25
+ * | identify | Without email |
26
+ * | email | With email |
27
+ *
28
+ * @example
29
+ * const client = new SnowTransfer("TOKEN")
30
+ * const self = await client.user.getSelf()
31
+ */
32
+ getSelf(): Promise<RESTGetAPICurrentUserResult>;
33
+ /**
34
+ * Get information about a user via Id
35
+ * @since 0.1.0
36
+ * @param userId Id of the user
37
+ * @returns [user object](https://discord.com/developers/docs/resources/user#user-object)
38
+ *
39
+ * @example
40
+ * const client = new SnowTransfer("TOKEN")
41
+ * const user = await client.user.getUser("userId")
42
+ */
43
+ getUser(userId: string): Promise<RESTGetAPIUserResult>;
44
+ /**
45
+ * Update the current user
46
+ * @since 0.18.0
47
+ * @param data The new data of the CurrentUser
48
+ * @returns [user object](https://discord.com/developers/docs/resources/user#user-object)
49
+ *
50
+ * @example
51
+ * // update the avatar of the user
52
+ * const client = new SnowTransfer("TOKEN")
53
+ * const fileData = fs.readFileSync("new_avatar.png") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods may lag your bot.
54
+ * const updateData = \{
55
+ * avatar: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String
56
+ * \}
57
+ * client.user.editSelf(updateData)
58
+ */
59
+ editSelf(data: RESTPatchAPICurrentUserJSONBody): Promise<RESTPatchAPICurrentUserResult>;
60
+ /**
61
+ * Get guilds of the current user
62
+ * @since 0.1.0
63
+ * @param options Options for getting guilds
64
+ * @returns Array of [partial guild objects](https://discord.com/developers/docs/resources/guild#guild-object)
65
+ *
66
+ * @example
67
+ * const client = new SnowTransfer("TOKEN")
68
+ * const guilds = await client.user.getGuilds()
69
+ */
70
+ getGuilds(options?: RESTGetAPICurrentUserGuildsQuery): Promise<RESTGetAPICurrentUserGuildsResult>;
71
+ /**
72
+ * Leaves a guild
73
+ * @since 0.1.0
74
+ * @param guildId Id of the guild
75
+ * @returns Resolves the Promise on successful execution
76
+ *
77
+ * @example
78
+ * const client = new SnowTransfer("TOKEN")
79
+ * client.user.leaveGuild("guildId")
80
+ */
81
+ leaveGuild(guildId: string): Promise<RESTDeleteAPICurrentUserGuildResult>;
82
+ /**
83
+ * Create a direct message channel with another user
84
+ *
85
+ * **You can not create a dm with another bot**
86
+ * @since 0.1.0
87
+ * @param userId Id of the user to create the direct message channel with
88
+ * @returns A [DM channel](https://discord.com/developers/docs/resources/channel#channel-object)
89
+ *
90
+ * @example
91
+ * // Create a dm channel and send "hi" to it
92
+ * const client = new SnowTransfer("TOKEN")
93
+ * const channel = await client.user.createDirectMessageChannel("other user id")
94
+ * client.channel.createMessage(channel.id, "hi")
95
+ */
96
+ createDirectMessageChannel(userId: string): Promise<RESTPostAPICurrentUserCreateDMChannelResult>;
97
+ /**
98
+ * Create a group direct message channel with other users
99
+ * @since 0.7.0
100
+ * @param data An object containing a list of access tokens with gdm.join and optionally, a nickname dictionary keyed by user IDs with strings as values
101
+ * @returns A [DM channel](https://discord.com/developers/docs/resources/channel#channel-object)
102
+ *
103
+ * | OAUTH2 Scopes | Condition |
104
+ * |---------------|----------------------|
105
+ * | gdm.join | always for each user |
106
+ *
107
+ * @example
108
+ * // Create a group dm channel and send "hi" to it
109
+ * const client = new SnowTransfer("TOKEN")
110
+ * const channel = await client.user.createGroupDirectMessageChannel({ access_tokens: ["user 1 access token", "user 2 access token"], nicks: { "320067006521147393": "Brad", "128392910574977024": "Wolke" } })
111
+ * client.channel.createMessage(channel.id, "hi")
112
+ */
113
+ createGroupDirectMessageChannel(data: {
114
+ access_tokens: Array<string>;
115
+ nicks?: {
116
+ [userId: string]: string;
117
+ };
118
+ }): Promise<RESTPostAPICurrentUserCreateDMChannelResult>;
119
+ /**
120
+ * Returns a list of connections for the current user
121
+ * @since 0.7.0
122
+ * @returns A list of [connections](https://discord.com/developers/docs/resources/user#connection-object)
123
+ *
124
+ * | OAUTH2 Scopes | Condition |
125
+ * |---------------|-----------|
126
+ * | connections | always |
127
+ *
128
+ * @example
129
+ * // Get all user's connections
130
+ * const client = new SnowTransfer("TOKEN")
131
+ * const connections = await client.user.getConnections()
132
+ */
133
+ getConnections(): Promise<RESTGetAPICurrentUserConnectionsResult>;
134
+ /**
135
+ * Gets a role connection for the current user
136
+ * @since 0.7.0
137
+ * @param appId Id of the application
138
+ * @returns An [Application role connection](https://discord.com/developers/docs/resources/user#application-role-connection-object)
139
+ *
140
+ * | OAUTH2 Scopes | Condition |
141
+ * |------------------------|-----------|
142
+ * | role_connections.write | always |
143
+ *
144
+ * @example
145
+ * // Get a role connection for an app
146
+ * const client = new SnowTransfer("TOKEN")
147
+ * const connection = await client.user.getApplicationRoleConnection("app id")
148
+ */
149
+ getApplicationRoleConnection(appId: string): Promise<RESTGetAPICurrentUserApplicationRoleConnectionResult>;
150
+ /**
151
+ * Updates a role connection for the current user
152
+ * @since 0.18.0
153
+ * @param appId Id of the application
154
+ * @returns An [Application role connection](https://discord.com/developers/docs/resources/user#application-role-connection-object)
155
+ *
156
+ * | OAUTH2 Scopes | Condition |
157
+ * |------------------------|-----------|
158
+ * | role_connections.write | always |
159
+ *
160
+ * @example
161
+ * // Updates a role connection for an app
162
+ * const client = new SnowTransfer("TOKEN")
163
+ * const connection = await client.user.editApplicationRoleConnection("app id", { platform_name: "some platform", platform_username: "Cool user 22" })
164
+ */
165
+ editApplicationRoleConnection(appId: string, data: RESTPutAPICurrentUserApplicationRoleConnectionJSONBody): Promise<RESTPutAPICurrentUserApplicationRoleConnectionResult>;
166
+ }
167
+ export = UserMethods;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ const Endpoints = require("../Endpoints");
3
+ /**
4
+ * Methods for interacting with users
5
+ * @since 0.1.0
6
+ */
7
+ class UserMethods {
8
+ requestHandler;
9
+ /**
10
+ * Create a new User Method handler
11
+ *
12
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
13
+ *
14
+ * You can access the methods listed via `client.user.method`, where `client` is an initialized SnowTransfer instance
15
+ * @param requestHandler
16
+ */
17
+ constructor(requestHandler) {
18
+ this.requestHandler = requestHandler;
19
+ }
20
+ /**
21
+ * Get information about the CurrentUser
22
+ * @since 0.1.0
23
+ * @returns A [user object](https://discord.com/developers/docs/resources/user#user-object)
24
+ *
25
+ * | OAUTH2 Scopes | Condition |
26
+ * |---------------|---------------|
27
+ * | identify | Without email |
28
+ * | email | With email |
29
+ *
30
+ * @example
31
+ * const client = new SnowTransfer("TOKEN")
32
+ * const self = await client.user.getSelf()
33
+ */
34
+ async getSelf() {
35
+ return this.requestHandler.request(Endpoints.USER("@me"), {}, "get", "json");
36
+ }
37
+ /**
38
+ * Get information about a user via Id
39
+ * @since 0.1.0
40
+ * @param userId Id of the user
41
+ * @returns [user object](https://discord.com/developers/docs/resources/user#user-object)
42
+ *
43
+ * @example
44
+ * const client = new SnowTransfer("TOKEN")
45
+ * const user = await client.user.getUser("userId")
46
+ */
47
+ async getUser(userId) {
48
+ return this.requestHandler.request(Endpoints.USER(userId), {}, "get", "json");
49
+ }
50
+ /**
51
+ * Update the current user
52
+ * @since 0.18.0
53
+ * @param data The new data of the CurrentUser
54
+ * @returns [user object](https://discord.com/developers/docs/resources/user#user-object)
55
+ *
56
+ * @example
57
+ * // update the avatar of the user
58
+ * const client = new SnowTransfer("TOKEN")
59
+ * const fileData = fs.readFileSync("new_avatar.png") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods may lag your bot.
60
+ * const updateData = \{
61
+ * avatar: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String
62
+ * \}
63
+ * client.user.editSelf(updateData)
64
+ */
65
+ async editSelf(data) {
66
+ return this.requestHandler.request(Endpoints.USER("@me"), {}, "patch", "json", data);
67
+ }
68
+ /**
69
+ * Get guilds of the current user
70
+ * @since 0.1.0
71
+ * @param options Options for getting guilds
72
+ * @returns Array of [partial guild objects](https://discord.com/developers/docs/resources/guild#guild-object)
73
+ *
74
+ * @example
75
+ * const client = new SnowTransfer("TOKEN")
76
+ * const guilds = await client.user.getGuilds()
77
+ */
78
+ async getGuilds(options) {
79
+ return this.requestHandler.request(Endpoints.USER_GUILDS("@me"), options ?? {}, "get", "json");
80
+ }
81
+ /**
82
+ * Leaves a guild
83
+ * @since 0.1.0
84
+ * @param guildId Id of the guild
85
+ * @returns Resolves the Promise on successful execution
86
+ *
87
+ * @example
88
+ * const client = new SnowTransfer("TOKEN")
89
+ * client.user.leaveGuild("guildId")
90
+ */
91
+ async leaveGuild(guildId) {
92
+ return this.requestHandler.request(Endpoints.USER_GUILD("@me", guildId), {}, "delete", "json");
93
+ }
94
+ /**
95
+ * Create a direct message channel with another user
96
+ *
97
+ * **You can not create a dm with another bot**
98
+ * @since 0.1.0
99
+ * @param userId Id of the user to create the direct message channel with
100
+ * @returns A [DM channel](https://discord.com/developers/docs/resources/channel#channel-object)
101
+ *
102
+ * @example
103
+ * // Create a dm channel and send "hi" to it
104
+ * const client = new SnowTransfer("TOKEN")
105
+ * const channel = await client.user.createDirectMessageChannel("other user id")
106
+ * client.channel.createMessage(channel.id, "hi")
107
+ */
108
+ async createDirectMessageChannel(userId) {
109
+ return this.requestHandler.request(Endpoints.USER_CHANNELS("@me"), {}, "post", "json", { recipient_id: userId });
110
+ }
111
+ /**
112
+ * Create a group direct message channel with other users
113
+ * @since 0.7.0
114
+ * @param data An object containing a list of access tokens with gdm.join and optionally, a nickname dictionary keyed by user IDs with strings as values
115
+ * @returns A [DM channel](https://discord.com/developers/docs/resources/channel#channel-object)
116
+ *
117
+ * | OAUTH2 Scopes | Condition |
118
+ * |---------------|----------------------|
119
+ * | gdm.join | always for each user |
120
+ *
121
+ * @example
122
+ * // Create a group dm channel and send "hi" to it
123
+ * const client = new SnowTransfer("TOKEN")
124
+ * const channel = await client.user.createGroupDirectMessageChannel({ access_tokens: ["user 1 access token", "user 2 access token"], nicks: { "320067006521147393": "Brad", "128392910574977024": "Wolke" } })
125
+ * client.channel.createMessage(channel.id, "hi")
126
+ */
127
+ async createGroupDirectMessageChannel(data) {
128
+ return this.requestHandler.request(Endpoints.USER_CHANNELS("@me"), {}, "post", "json", data);
129
+ }
130
+ /**
131
+ * Returns a list of connections for the current user
132
+ * @since 0.7.0
133
+ * @returns A list of [connections](https://discord.com/developers/docs/resources/user#connection-object)
134
+ *
135
+ * | OAUTH2 Scopes | Condition |
136
+ * |---------------|-----------|
137
+ * | connections | always |
138
+ *
139
+ * @example
140
+ * // Get all user's connections
141
+ * const client = new SnowTransfer("TOKEN")
142
+ * const connections = await client.user.getConnections()
143
+ */
144
+ async getConnections() {
145
+ return this.requestHandler.request(Endpoints.USER_CONNECTIONS("@me"), {}, "get", "json");
146
+ }
147
+ /**
148
+ * Gets a role connection for the current user
149
+ * @since 0.7.0
150
+ * @param appId Id of the application
151
+ * @returns An [Application role connection](https://discord.com/developers/docs/resources/user#application-role-connection-object)
152
+ *
153
+ * | OAUTH2 Scopes | Condition |
154
+ * |------------------------|-----------|
155
+ * | role_connections.write | always |
156
+ *
157
+ * @example
158
+ * // Get a role connection for an app
159
+ * const client = new SnowTransfer("TOKEN")
160
+ * const connection = await client.user.getApplicationRoleConnection("app id")
161
+ */
162
+ async getApplicationRoleConnection(appId) {
163
+ return this.requestHandler.request(Endpoints.USER_APPLICATION_ROLE_CONNECTION("@me", appId), {}, "get", "json");
164
+ }
165
+ /**
166
+ * Updates a role connection for the current user
167
+ * @since 0.18.0
168
+ * @param appId Id of the application
169
+ * @returns An [Application role connection](https://discord.com/developers/docs/resources/user#application-role-connection-object)
170
+ *
171
+ * | OAUTH2 Scopes | Condition |
172
+ * |------------------------|-----------|
173
+ * | role_connections.write | always |
174
+ *
175
+ * @example
176
+ * // Updates a role connection for an app
177
+ * const client = new SnowTransfer("TOKEN")
178
+ * const connection = await client.user.editApplicationRoleConnection("app id", { platform_name: "some platform", platform_username: "Cool user 22" })
179
+ */
180
+ async editApplicationRoleConnection(appId, data) {
181
+ return this.requestHandler.request(Endpoints.USER_APPLICATION_ROLE_CONNECTION("@me", appId), {}, "put", "json", data);
182
+ }
183
+ }
184
+ module.exports = UserMethods;
@@ -0,0 +1,44 @@
1
+ import type { RequestHandler } from "../RequestHandler";
2
+ import type { RESTGetAPIVoiceRegionsResult, APIVoiceState } from "discord-api-types/v10";
3
+ /**
4
+ * Methods for interacting with voice
5
+ * @since 0.1.0
6
+ */
7
+ declare class VoiceMethods {
8
+ readonly requestHandler: RequestHandler;
9
+ /**
10
+ * Create a new Voice Method Handler
11
+ *
12
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
13
+ *
14
+ * You can access the methods listed via `client.voice.method`, where `client` is an initialized SnowTransfer instance
15
+ * @param requestHandler request handler that calls the rest api
16
+ */
17
+ constructor(requestHandler: RequestHandler);
18
+ /**
19
+ * Get currently available voice regions that can be used when creating servers
20
+ * @since 0.1.0
21
+ * @returns Array of [voice region](https://discord.com/developers/docs/resources/voice#voice-region-object) objects
22
+ *
23
+ * @example
24
+ * const client = new SnowTransfer("TOKEN")
25
+ * const regions = await client.voice.getVoiceRegions()
26
+ */
27
+ getVoiceRegions(): Promise<RESTGetAPIVoiceRegionsResult>;
28
+ /**
29
+ * Get the CurrentUser's voice state for a guild
30
+ * @since 0.10.6
31
+ * @param guildId Id of the guild
32
+ * @returns A [voice state](https://discord.com/developers/docs/resources/voice#voice-state-object) object
33
+ */
34
+ getCurrentUserVoiceState(guildId: string): Promise<APIVoiceState>;
35
+ /**
36
+ * Get a user's voice state for a guild
37
+ * @since 0.10.6
38
+ * @param guildId Id of the guild
39
+ * @param userId Id of the user
40
+ * @returns A [voice state](https://discord.com/developers/docs/resources/voice#voice-state-object) object
41
+ */
42
+ getUserVoiceState(guildId: string, userId: string): Promise<APIVoiceState>;
43
+ }
44
+ export = VoiceMethods;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ const Endpoints = require("../Endpoints");
3
+ /**
4
+ * Methods for interacting with voice
5
+ * @since 0.1.0
6
+ */
7
+ class VoiceMethods {
8
+ requestHandler;
9
+ /**
10
+ * Create a new Voice Method Handler
11
+ *
12
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
13
+ *
14
+ * You can access the methods listed via `client.voice.method`, where `client` is an initialized SnowTransfer instance
15
+ * @param requestHandler request handler that calls the rest api
16
+ */
17
+ constructor(requestHandler) {
18
+ this.requestHandler = requestHandler;
19
+ }
20
+ /**
21
+ * Get currently available voice regions that can be used when creating servers
22
+ * @since 0.1.0
23
+ * @returns Array of [voice region](https://discord.com/developers/docs/resources/voice#voice-region-object) objects
24
+ *
25
+ * @example
26
+ * const client = new SnowTransfer("TOKEN")
27
+ * const regions = await client.voice.getVoiceRegions()
28
+ */
29
+ async getVoiceRegions() {
30
+ return this.requestHandler.request(Endpoints.VOICE_REGIONS, {}, "get", "json");
31
+ }
32
+ /**
33
+ * Get the CurrentUser's voice state for a guild
34
+ * @since 0.10.6
35
+ * @param guildId Id of the guild
36
+ * @returns A [voice state](https://discord.com/developers/docs/resources/voice#voice-state-object) object
37
+ */
38
+ async getCurrentUserVoiceState(guildId) {
39
+ return this.requestHandler.request(Endpoints.USER_GUILD_VOICE_STATE(guildId, "@me"), {}, "get", "json");
40
+ }
41
+ /**
42
+ * Get a user's voice state for a guild
43
+ * @since 0.10.6
44
+ * @param guildId Id of the guild
45
+ * @param userId Id of the user
46
+ * @returns A [voice state](https://discord.com/developers/docs/resources/voice#voice-state-object) object
47
+ */
48
+ async getUserVoiceState(guildId, userId) {
49
+ return this.requestHandler.request(Endpoints.USER_GUILD_VOICE_STATE(guildId, userId), {}, "get", "json");
50
+ }
51
+ }
52
+ module.exports = VoiceMethods;