snowtransfer 0.17.7 → 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 (55) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +4 -5
  4. package/dist/Constants.d.ts +59 -0
  5. package/dist/Constants.js +123 -0
  6. package/dist/Endpoints.d.ts +120 -0
  7. package/dist/Endpoints.js +121 -0
  8. package/dist/RequestHandler.d.ts +258 -0
  9. package/dist/RequestHandler.js +629 -0
  10. package/dist/SnowTransfer.d.ts +70 -0
  11. package/dist/SnowTransfer.js +105 -0
  12. package/dist/StateMachine.d.ts +89 -0
  13. package/dist/StateMachine.js +208 -0
  14. package/dist/StateMachineGraph.d.ts +3 -0
  15. package/dist/StateMachineGraph.js +23 -0
  16. package/dist/Types.d.ts +76 -0
  17. package/dist/Types.js +2 -0
  18. package/dist/index.d.ts +25 -4102
  19. package/dist/index.js +63 -46
  20. package/dist/methods/Assets.d.ts +290 -0
  21. package/dist/methods/Assets.js +326 -0
  22. package/dist/methods/AuditLog.d.ts +40 -0
  23. package/dist/methods/AuditLog.js +44 -0
  24. package/dist/methods/AutoModeration.d.ts +122 -0
  25. package/dist/methods/AutoModeration.js +135 -0
  26. package/dist/methods/Bot.d.ts +65 -0
  27. package/dist/methods/Bot.js +75 -0
  28. package/dist/methods/Channel.d.ts +866 -0
  29. package/dist/methods/Channel.js +982 -0
  30. package/dist/methods/Entitlements.d.ts +87 -0
  31. package/dist/methods/Entitlements.js +99 -0
  32. package/dist/methods/Guild.d.ts +722 -0
  33. package/dist/methods/Guild.js +785 -0
  34. package/dist/methods/GuildScheduledEvent.d.ts +138 -0
  35. package/dist/methods/GuildScheduledEvent.js +155 -0
  36. package/dist/methods/GuildTemplate.d.ts +110 -0
  37. package/dist/methods/GuildTemplate.js +124 -0
  38. package/dist/methods/Interaction.d.ts +339 -0
  39. package/dist/methods/Interaction.js +359 -0
  40. package/dist/methods/Invite.d.ts +81 -0
  41. package/dist/methods/Invite.js +107 -0
  42. package/dist/methods/Sku.d.ts +58 -0
  43. package/dist/methods/Sku.js +66 -0
  44. package/dist/methods/StageInstance.d.ts +86 -0
  45. package/dist/methods/StageInstance.js +97 -0
  46. package/dist/methods/User.d.ts +167 -0
  47. package/dist/methods/User.js +184 -0
  48. package/dist/methods/Voice.d.ts +44 -0
  49. package/dist/methods/Voice.js +52 -0
  50. package/dist/methods/Webhook.d.ts +265 -0
  51. package/dist/methods/Webhook.js +256 -0
  52. package/dist/tokenless.d.ts +19 -0
  53. package/dist/tokenless.js +31 -0
  54. package/package.json +16 -11
  55. package/dist/index.js.map +0 -1
@@ -0,0 +1,326 @@
1
+ "use strict";
2
+ const Constants = require("../Constants");
3
+ const Endpoints = require("../Endpoints");
4
+ /**
5
+ * Methods for interacting with assets like emojis and stickers for a guild/app
6
+ * @since 0.13.0
7
+ */
8
+ class AssetsMethods {
9
+ requestHandler;
10
+ /**
11
+ * Create a new Assets 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.assets.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
+ * Get a list of emojis of a guild
23
+ * @since 0.13.0
24
+ * @param guildId Id of the guild
25
+ * @returns Array of [emoji objects](https://discord.com/developers/docs/resources/emoji#emoji-object)
26
+ *
27
+ * @example
28
+ * const client = new SnowTransfer("TOKEN")
29
+ * const emojis = await client.assets.getGuildEmojis("guild id")
30
+ */
31
+ async getGuildEmojis(guildId) {
32
+ return this.requestHandler.request(Endpoints.GUILD_EMOJIS(guildId), {}, "get", "json");
33
+ }
34
+ /**
35
+ * Get an emoji from a guild via id
36
+ * @since 0.13.0
37
+ * @param guildId Id of the guild
38
+ * @param emojiId Id of the emoji
39
+ * @returns [Emoji object](https://discord.com/developers/docs/resources/emoji#emoji-object)
40
+ *
41
+ * @example
42
+ * const client = new SnowTransfer("TOKEN")
43
+ * const emoji = await client.assets.getGuildEmoji("guild id", "emoji id")
44
+ */
45
+ async getGuildEmoji(guildId, emojiId) {
46
+ return this.requestHandler.request(Endpoints.GUILD_EMOJI(guildId, emojiId), {}, "get", "json");
47
+ }
48
+ /**
49
+ * Create a new Emoji in a guild
50
+ * @since 0.13.0
51
+ * @param guildId Id of the guild
52
+ * @param data Emoji data, check the example
53
+ * @param reason Reason for creating the emoji
54
+ * @returns [Emoji object](https://discord.com/developers/docs/resources/emoji#emoji-object)
55
+ *
56
+ * | Permissions needed | Condition |
57
+ * |----------------------------|-----------|
58
+ * | MANAGE_EMOJIS_AND_STICKERS | always |
59
+ *
60
+ * @example
61
+ * // upload a simple png emoji with a name of "niceEmoji"
62
+ * const client = new SnowTransfer("TOKEN")
63
+ * const fileData = fs.readFileSync("nice_emoji.png") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods pause the thread.
64
+ * const emojiData = \{
65
+ * name: "niceEmoji",
66
+ * image: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String
67
+ * \}
68
+ * client.assets.createGuildEmoji("guild id", emojiData)
69
+ */
70
+ async createGuildEmoji(guildId, data, reason) {
71
+ return this.requestHandler.request(Endpoints.GUILD_EMOJIS(guildId), {}, "post", "json", data, Constants.reasonHeader(reason));
72
+ }
73
+ /**
74
+ * Update an existing emoji from a guild
75
+ * @since 0.18.0
76
+ * @param guildId Id of the guild
77
+ * @param emojiId Id of the emoji
78
+ * @param data Emoji data
79
+ * @param reason Reason for updating the emoji
80
+ * @returns [Emoji object](https://discord.com/developers/docs/resources/emoji#emoji-object)
81
+ *
82
+ * | Permissions needed | Condition |
83
+ * |----------------------------|-----------|
84
+ * | MANAGE_EMOJIS_AND_STICKERS | always |
85
+ *
86
+ * @example
87
+ * // Change the name of an existing emoji to "niceEmote"
88
+ * const client = new SnowTransfer("TOKEN")
89
+ * const emojiData = {
90
+ * name: "niceEmote"
91
+ * }
92
+ * client.assets.editGuildEmoji("guild id", "emoji id", emojiData)
93
+ */
94
+ async editGuildEmoji(guildId, emojiId, data, reason) {
95
+ return this.requestHandler.request(Endpoints.GUILD_EMOJI(guildId, emojiId), {}, "patch", "json", data, Constants.reasonHeader(reason));
96
+ }
97
+ /**
98
+ * Delete an emoji from a guild
99
+ * @since 0.13.0
100
+ * @param guildId Id of the guild
101
+ * @param emojiId Id of the emoji
102
+ * @param reason Reason for deleting the emoji
103
+ * @returns Resolves the Promise on successful execution
104
+ *
105
+ * | Permissions needed | Condition |
106
+ * |----------------------------|-----------|
107
+ * | MANAGE_EMOJIS_AND_STICKERS | always |
108
+ *
109
+ * @example
110
+ * // Deletes an emoji because it wasn't nice
111
+ * const client = new SnowTransfer("TOKEN")
112
+ * client.assets.deleteGuildEmoji("guild id", "emoji id", "wasn't nice")
113
+ */
114
+ async deleteGuildEmoji(guildId, emojiId, reason) {
115
+ return this.requestHandler.request(Endpoints.GUILD_EMOJI(guildId, emojiId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
116
+ }
117
+ /**
118
+ * Get a global sticker
119
+ * @since 0.13.0
120
+ * @param stickerId Id of the sticker
121
+ * @returns [Sticker object](https://discord.com/developers/docs/resources/sticker#sticker-object)
122
+ *
123
+ * @example
124
+ * const client = new SnowTransfer("TOKEN")
125
+ * const sticker = await client.assets.getSticker("sticker id")
126
+ */
127
+ async getSticker(stickerId) {
128
+ return this.requestHandler.request(Endpoints.STICKER(stickerId), {}, "get", "json");
129
+ }
130
+ /**
131
+ * Get all guild stickers
132
+ * @since 0.13.0
133
+ * @param guildId Id of the guild
134
+ * @returns An Array of [sticker objects](https://discord.com/developers/docs/resources/sticker#sticker-object)
135
+ *
136
+ * | Permissions needed | Condition |
137
+ * |----------------------------|---------------------------------------------|
138
+ * | MANAGE_EMOJIS_AND_STICKERS | if the CurrentUser desires the `user` field |
139
+ *
140
+ * @example
141
+ * const client = new SnowTransfer("TOKEN")
142
+ * const stickers = await client.assets.getGuildStickers("guild id")
143
+ */
144
+ async getGuildStickers(guildId) {
145
+ return this.requestHandler.request(Endpoints.GUILD_STICKERS(guildId), {}, "get", "json");
146
+ }
147
+ /**
148
+ * Get a guild sticker
149
+ * @since 0.13.0
150
+ * @param guildId Id of the guild
151
+ * @param stickerId Id of the sticker
152
+ * @returns A [sticker object](https://discord.com/developers/docs/resources/sticker#sticker-object)
153
+ *
154
+ * | Permissions needed | Condition |
155
+ * |----------------------------|---------------------------------------------|
156
+ * | MANAGE_EMOJIS_AND_STICKERS | if the CurrentUser desires the `user` field |
157
+ *
158
+ * @example
159
+ * const client = new SnowTransfer("TOKEN")
160
+ * const sticker = await client.assets.getGuildSticker("guild id", "sticker id")
161
+ */
162
+ async getGuildSticker(guildId, stickerId) {
163
+ return this.requestHandler.request(Endpoints.GUILD_STICKER(guildId, stickerId), {}, "get", "json");
164
+ }
165
+ /**
166
+ * Create a guild sticker
167
+ * @since 0.13.0
168
+ * @param guildId Id of the guild
169
+ * @param data Sticker data
170
+ * @param reason Reason for creating the sticker
171
+ * @returns A [sticker object](https://discord.com/developers/docs/resources/sticker#sticker-object)
172
+ *
173
+ * | Permissions needed | Condition |
174
+ * |-----------------------------|-------------------------------------------------|
175
+ * | MANAGE_EMOJIS_AND_STICKERS | always |
176
+ *
177
+ * | Guild Features needed | Condition |
178
+ * |-----------------------|-------------------------------------------------|
179
+ * | VERIFIED or PARTNERED | If CurrentUser tries to create a LOTTIE sticker |
180
+ *
181
+ * @example
182
+ * // Creates a LOTTIE sticker
183
+ * const client = new SnowTransfer("TOKEN")
184
+ * const fileData = fs.readFileSync("nice_sticker.json") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods pause the thread.
185
+ * const stickerData = {
186
+ * name: "niceSticker",
187
+ * file: fileData,
188
+ * description: "A very nice sticker",
189
+ * tags: "nice,sticker",
190
+ * }
191
+ * const sticker = await client.assets.createGuildSticker("guild id", stickerData)
192
+ */
193
+ async createGuildSticker(guildId, data, reason) {
194
+ const form = new FormData();
195
+ for (const [key, value] of Object.entries(data)) {
196
+ await Constants.standardAddToFormHandler(form, key, value);
197
+ }
198
+ return this.requestHandler.request(Endpoints.GUILD_STICKERS(guildId), {}, "post", "multipart", form, Constants.reasonHeader(reason));
199
+ }
200
+ /**
201
+ * Update a guild sticker
202
+ * @since 0.18.0
203
+ * @param guildId Id of the guild
204
+ * @param stickerId Id of the sticker
205
+ * @param data Sticker data
206
+ * @param reason Reason for updating the sticker
207
+ * @returns A [sticker object](https://discord.com/developers/docs/resources/sticker#sticker-object)
208
+ *
209
+ * | Permissions needed | Condition |
210
+ * |----------------------------|-----------|
211
+ * | MANAGE_EMOJIS_AND_STICKERS | always |
212
+ *
213
+ * @example
214
+ * // Updates a sticker's name to "nicerSticker"
215
+ * const client = new SnowTransfer("TOKEN")
216
+ * const sticker = await client.assets.editGuildSticker("guild id", "sticker id", { name: "nicerSticker" }, "because it was nicer")
217
+ */
218
+ async editGuildSticker(guildId, stickerId, data, reason) {
219
+ return this.requestHandler.request(Endpoints.GUILD_STICKER(guildId, stickerId), {}, "patch", "json", data, Constants.reasonHeader(reason));
220
+ }
221
+ /**
222
+ * Delete a guild sticker
223
+ * @since 0.13.0
224
+ * @param guildId Id of the guild
225
+ * @param stickerId Id of the sticker
226
+ * @param reason Reason for deleting the sticker
227
+ * @returns Resolves the Promise on successful execution
228
+ *
229
+ * | Permissions needed | Condition |
230
+ * |----------------------------|-----------|
231
+ * | MANAGE_EMOJIS_AND_STICKERS | always |
232
+ *
233
+ * @example
234
+ * // Deletes a sticker because it was too nice
235
+ * const client = new SnowTransfer("TOKEN")
236
+ * client.assets.deleteGuildSticker("guild id", "sticker id", "It was too nice")
237
+ */
238
+ async deleteGuildSticker(guildId, stickerId, reason) {
239
+ return this.requestHandler.request(Endpoints.GUILD_STICKER(guildId, stickerId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
240
+ }
241
+ /**
242
+ * Get all emojis for an app
243
+ * @since 0.13.0
244
+ * @param appId Id of the app
245
+ * @returns An Array of [emoji objects](https://discord.com/developers/docs/resources/emoji#emoji-object)
246
+ *
247
+ * @example
248
+ * // Gets all emojis for an app
249
+ * const client = new SnowTransfer("TOKEN")
250
+ * const emojis = await client.assets.getAppEmojis("app id")
251
+ */
252
+ async getAppEmojis(appId) {
253
+ return this.requestHandler.request(Endpoints.APPLICATION_EMOJIS(appId), {}, "get", "json");
254
+ }
255
+ /**
256
+ * Get an emoji for an app by id
257
+ * @since 0.13.0
258
+ * @param appId Id of the app
259
+ * @param emojiId Id of the emoji
260
+ * @returns [emoji object](https://discord.com/developers/docs/resources/emoji#emoji-object)
261
+ *
262
+ * @example
263
+ * // Gets an emoji by id from an app
264
+ * const client = new SnowTransfer("TOKEN")
265
+ * const emoji = await client.assets.getAppEmoji("app id", "emoji id")
266
+ */
267
+ async getAppEmoji(appId, emojiId) {
268
+ return this.requestHandler.request(Endpoints.APPLICATION_EMOJI(appId, emojiId), {}, "get", "json");
269
+ }
270
+ /**
271
+ * Create an emoji for an app
272
+ * @since 0.13.0
273
+ * @param appId Id of the app
274
+ * @param data Emoji data, check the example
275
+ * @returns [emoji object](https://discord.com/developers/docs/resources/emoji#emoji-object)
276
+ *
277
+ * @example
278
+ * // Creates an emoji for an app with a NICER name
279
+ * const client = new SnowTransfer("TOKEN")
280
+ * const fileData = fs.readFileSync("even_nicer_emoji.png") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods pause the thread.
281
+ * const emojiData = \{
282
+ * name: "nicerEmoji",
283
+ * image: `data:image/png;base64,${fileData.toString("base64")}` // base64 data url: data:mimetype;base64,base64String
284
+ * \}
285
+ * client.assets.createAppEmoji("app id", emojiData)
286
+ */
287
+ async createAppEmoji(appId, data) {
288
+ return this.requestHandler.request(Endpoints.APPLICATION_EMOJIS(appId), {}, "post", "json", data);
289
+ }
290
+ /**
291
+ * Updates an emoji for an app
292
+ * @since 0.18.0
293
+ * @param appId Id of the app
294
+ * @param emojiId Id of the emoji
295
+ * @param data Emoji data
296
+ * @returns [emoji object](https://discord.com/developers/docs/resources/emoji#emoji-object)
297
+ *
298
+ * @example
299
+ * // The emoji we just made is actually the nicest emoji ever. Gotta reflect that
300
+ * const client = new SnowTransfer("TOKEN")
301
+ * const emojiData = {
302
+ * name: "nicestEmoji"
303
+ * }
304
+ * client.assets.editAppEmoji("app id", "emoji id", emojiData)
305
+ */
306
+ async editAppEmoji(appId, emojiId, data) {
307
+ return this.requestHandler.request(Endpoints.APPLICATION_EMOJI(appId, emojiId), {}, "patch", "json", data);
308
+ }
309
+ /**
310
+ * Delete an emoji for an app
311
+ * @since 0.13.0
312
+ * @param appId Id of the app
313
+ * @param emojiId Id of the emoji
314
+ * @returns Resolves the Promise on successful execution
315
+ *
316
+ * @example
317
+ * // The emoji was TOO POWERFUL. WE NEED TO REMOVE IT
318
+ * const client = new SnowTransfer("TOKEN")
319
+ * client.assets.deleteAppEmoji("app id", "emoji id") // OH GOD THE UNIVERSE IS COLLAPSING
320
+ * // We're safe. The emoji is gone. For now...
321
+ */
322
+ async deleteAppEmoji(appId, emojiId) {
323
+ return this.requestHandler.request(Endpoints.APPLICATION_EMOJI(appId, emojiId), {}, "delete", "json");
324
+ }
325
+ }
326
+ module.exports = AssetsMethods;
@@ -0,0 +1,40 @@
1
+ import type { RequestHandler } from "../RequestHandler";
2
+ import type { RESTGetAPIAuditLogQuery, RESTGetAPIAuditLogResult } from "discord-api-types/v10";
3
+ /**
4
+ * Methods for interacting with Guild Audit Logs
5
+ * @since 0.2.0
6
+ */
7
+ declare class AuditLogMethods {
8
+ readonly requestHandler: RequestHandler;
9
+ /**
10
+ * Create a new Audit Log 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.auditLog.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 the audit logs of the specified guild id
20
+ * @since 0.2.0
21
+ * @param guildId id of a guild
22
+ * @param options optional audit log filter values
23
+ * @returns An object with [audit log data](https://discord.com/developers/docs/resources/audit-log#audit-log-object)
24
+ *
25
+ * | Permissions needed | Condition |
26
+ * |--------------------|-----------|
27
+ * | VIEW_AUDIT_LOG | always |
28
+ *
29
+ * @example
30
+ * // Get an audit log entry of user 12345678901234567 updating themself (24 is MEMBER_UPDATE)
31
+ * const client = new SnowTransfer("TOKEN")
32
+ * const data = {
33
+ * user_id: "12345678901234567",
34
+ * action_type: 24,
35
+ * }
36
+ * const channel = await client.auditLog.getAuditLog("guild id", data)
37
+ */
38
+ getAuditLog(guildId: string, options?: RESTGetAPIAuditLogQuery): Promise<RESTGetAPIAuditLogResult>;
39
+ }
40
+ export = AuditLogMethods;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ const Endpoints = require("../Endpoints");
3
+ /**
4
+ * Methods for interacting with Guild Audit Logs
5
+ * @since 0.2.0
6
+ */
7
+ class AuditLogMethods {
8
+ requestHandler;
9
+ /**
10
+ * Create a new Audit Log 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.auditLog.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 the audit logs of the specified guild id
22
+ * @since 0.2.0
23
+ * @param guildId id of a guild
24
+ * @param options optional audit log filter values
25
+ * @returns An object with [audit log data](https://discord.com/developers/docs/resources/audit-log#audit-log-object)
26
+ *
27
+ * | Permissions needed | Condition |
28
+ * |--------------------|-----------|
29
+ * | VIEW_AUDIT_LOG | always |
30
+ *
31
+ * @example
32
+ * // Get an audit log entry of user 12345678901234567 updating themself (24 is MEMBER_UPDATE)
33
+ * const client = new SnowTransfer("TOKEN")
34
+ * const data = {
35
+ * user_id: "12345678901234567",
36
+ * action_type: 24,
37
+ * }
38
+ * const channel = await client.auditLog.getAuditLog("guild id", data)
39
+ */
40
+ async getAuditLog(guildId, options) {
41
+ return this.requestHandler.request(Endpoints.GUILD_AUDIT_LOGS(guildId), options, "get", "json");
42
+ }
43
+ }
44
+ module.exports = AuditLogMethods;
@@ -0,0 +1,122 @@
1
+ import type { RequestHandler } from "../RequestHandler";
2
+ import type { RESTGetAPIAutoModerationRulesResult, RESTGetAPIAutoModerationRuleResult, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIAutoModerationRuleResult, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIAutoModerationRuleResult, RESTDeleteAPIAutoModerationRuleResult } from "discord-api-types/v10";
3
+ /**
4
+ * Methods for interacting with guild auto moderation
5
+ * @since 0.7.0
6
+ */
7
+ declare class AutoModerationMethods {
8
+ readonly requestHandler: RequestHandler;
9
+ /**
10
+ * Create a new Auto Moderation 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.autoMod.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 all of the auto moderation rules from a guild
20
+ * @since 0.7.0
21
+ * @param guildId id of the guild
22
+ * @returns A list of [auto mod rules](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
23
+ *
24
+ * | Permissions needed | Condition |
25
+ * |--------------------|-----------|
26
+ * | MANAGE_GUILD | always |
27
+ *
28
+ * @example
29
+ * // gets all automod rules of a guild
30
+ * const client = new SnowTransfer("TOKEN")
31
+ * const rules = await client.autoMod.getAutoModerationRules("guild id")
32
+ */
33
+ getAutoModerationRules(guildId: string): Promise<RESTGetAPIAutoModerationRulesResult>;
34
+ /**
35
+ * Get a auto moderation rules from a guild
36
+ * @since 0.7.0
37
+ * @param guildId id of the guild
38
+ * @param ruleId id of the rule
39
+ * @returns An [auto mod rule](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
40
+ *
41
+ * | Permissions needed | Condition |
42
+ * |--------------------|-----------|
43
+ * | MANAGE_GUILD | always |
44
+ *
45
+ * @example
46
+ * // gets an automod rule from a guild
47
+ * const client = new SnowTransfer("TOKEN")
48
+ * const rule = await client.autoMod.getAutoModerationRule("guild id", "rule id")
49
+ */
50
+ getAutoModerationRule(guildId: string, ruleId: string): Promise<RESTGetAPIAutoModerationRuleResult>;
51
+ /**
52
+ * Create an auto moderation rule for a guild
53
+ * @since 0.7.0
54
+ * @param guildId id of the guild
55
+ * @param data the data of the auto moderation rule
56
+ * @param reason Reason for creating the auto moderation rule
57
+ * @returns An [auto mod rule](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
58
+ *
59
+ * | Permissions needed | Condition |
60
+ * |--------------------|-----------|
61
+ * | MANAGE_GUILD | always |
62
+ *
63
+ * @example
64
+ * const client = new SnowTransfer("TOKEN")
65
+ * const data = {
66
+ * name: "mention_spam_prevent",
67
+ * event_type: 1,
68
+ * trigger_type: 5,
69
+ * trigger_metadata: {
70
+ * mention_total_limit: 6
71
+ * },
72
+ * actions: [
73
+ * {
74
+ * type: 1
75
+ * }
76
+ * ]
77
+ * }
78
+ * const newRule = await client.autoMod.createAutoModerationRule("guild id", data)
79
+ */
80
+ createAutoModerationRule(guildId: string, data: RESTPostAPIAutoModerationRuleJSONBody, reason?: string): Promise<RESTPostAPIAutoModerationRuleResult>;
81
+ /**
82
+ * Edit an auto moderation rule for a guild
83
+ * @since 0.7.0
84
+ * @param guildId id of the guild
85
+ * @param ruleId id of the rule
86
+ * @param data the data of the auto moderation rule
87
+ * @param reason Reason for editing the auto moderation rule
88
+ * @returns An [auto mod rule](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
89
+ *
90
+ * | Permissions needed | Condition |
91
+ * |--------------------|-----------|
92
+ * | MANAGE_GUILD | always |
93
+ *
94
+ * @example
95
+ * // Turn on the rule I forgot was disabled by default
96
+ * const client = new SnowTransfer("TOKEN")
97
+ * const data = {
98
+ * name: "mention_spam_prevention",
99
+ * enabled: true,
100
+ * }
101
+ * const updatedRule = await client.autoMod.editAutoModerationRule("guild id", "rule id", data, "It's turned off by default and I forgor")
102
+ */
103
+ editAutoModerationRule(guildId: string, ruleId: string, data: RESTPatchAPIAutoModerationRuleJSONBody, reason?: string): Promise<RESTPatchAPIAutoModerationRuleResult>;
104
+ /**
105
+ * Deletes an auto moderation rule for a guild
106
+ * @since 0.7.0
107
+ * @param guildId id of the guild
108
+ * @param ruleId id of the rule
109
+ * @param reason Reason for deleting the rule
110
+ * @returns Resolves the Promise on successful execution
111
+ *
112
+ * | Permissions needed | Condition |
113
+ * |--------------------|-----------|
114
+ * | MANAGE_GUILD | always |
115
+ *
116
+ * @example
117
+ * const client = new SnowTransfer("TOKEN")
118
+ * client.autoMod.deleteAutoModerationRule("guild id", "rule id", "was useless")
119
+ */
120
+ deleteAutoModerationRule(guildId: string, ruleId: string, reason?: string): Promise<RESTDeleteAPIAutoModerationRuleResult>;
121
+ }
122
+ export = AutoModerationMethods;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ const Endpoints = require("../Endpoints");
3
+ const Constants = require("../Constants");
4
+ /**
5
+ * Methods for interacting with guild auto moderation
6
+ * @since 0.7.0
7
+ */
8
+ class AutoModerationMethods {
9
+ requestHandler;
10
+ /**
11
+ * Create a new Auto Moderation 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.autoMod.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
+ * Get all of the auto moderation rules from a guild
23
+ * @since 0.7.0
24
+ * @param guildId id of the guild
25
+ * @returns A list of [auto mod rules](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
26
+ *
27
+ * | Permissions needed | Condition |
28
+ * |--------------------|-----------|
29
+ * | MANAGE_GUILD | always |
30
+ *
31
+ * @example
32
+ * // gets all automod rules of a guild
33
+ * const client = new SnowTransfer("TOKEN")
34
+ * const rules = await client.autoMod.getAutoModerationRules("guild id")
35
+ */
36
+ async getAutoModerationRules(guildId) {
37
+ return this.requestHandler.request(Endpoints.GUILD_AUTO_MOD_RULES(guildId), {}, "get", "json");
38
+ }
39
+ /**
40
+ * Get a auto moderation rules from a guild
41
+ * @since 0.7.0
42
+ * @param guildId id of the guild
43
+ * @param ruleId id of the rule
44
+ * @returns An [auto mod rule](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
45
+ *
46
+ * | Permissions needed | Condition |
47
+ * |--------------------|-----------|
48
+ * | MANAGE_GUILD | always |
49
+ *
50
+ * @example
51
+ * // gets an automod rule from a guild
52
+ * const client = new SnowTransfer("TOKEN")
53
+ * const rule = await client.autoMod.getAutoModerationRule("guild id", "rule id")
54
+ */
55
+ async getAutoModerationRule(guildId, ruleId) {
56
+ return this.requestHandler.request(Endpoints.GUILD_AUTO_MOD_RULE(guildId, ruleId), {}, "get", "json");
57
+ }
58
+ /**
59
+ * Create an auto moderation rule for a guild
60
+ * @since 0.7.0
61
+ * @param guildId id of the guild
62
+ * @param data the data of the auto moderation rule
63
+ * @param reason Reason for creating the auto moderation rule
64
+ * @returns An [auto mod rule](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
65
+ *
66
+ * | Permissions needed | Condition |
67
+ * |--------------------|-----------|
68
+ * | MANAGE_GUILD | always |
69
+ *
70
+ * @example
71
+ * const client = new SnowTransfer("TOKEN")
72
+ * const data = {
73
+ * name: "mention_spam_prevent",
74
+ * event_type: 1,
75
+ * trigger_type: 5,
76
+ * trigger_metadata: {
77
+ * mention_total_limit: 6
78
+ * },
79
+ * actions: [
80
+ * {
81
+ * type: 1
82
+ * }
83
+ * ]
84
+ * }
85
+ * const newRule = await client.autoMod.createAutoModerationRule("guild id", data)
86
+ */
87
+ async createAutoModerationRule(guildId, data, reason) {
88
+ return this.requestHandler.request(Endpoints.GUILD_AUTO_MOD_RULES(guildId), {}, "post", "json", data, Constants.reasonHeader(reason));
89
+ }
90
+ /**
91
+ * Edit an auto moderation rule for a guild
92
+ * @since 0.7.0
93
+ * @param guildId id of the guild
94
+ * @param ruleId id of the rule
95
+ * @param data the data of the auto moderation rule
96
+ * @param reason Reason for editing the auto moderation rule
97
+ * @returns An [auto mod rule](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object)
98
+ *
99
+ * | Permissions needed | Condition |
100
+ * |--------------------|-----------|
101
+ * | MANAGE_GUILD | always |
102
+ *
103
+ * @example
104
+ * // Turn on the rule I forgot was disabled by default
105
+ * const client = new SnowTransfer("TOKEN")
106
+ * const data = {
107
+ * name: "mention_spam_prevention",
108
+ * enabled: true,
109
+ * }
110
+ * const updatedRule = await client.autoMod.editAutoModerationRule("guild id", "rule id", data, "It's turned off by default and I forgor")
111
+ */
112
+ async editAutoModerationRule(guildId, ruleId, data, reason) {
113
+ return this.requestHandler.request(Endpoints.GUILD_AUTO_MOD_RULE(guildId, ruleId), {}, "patch", "json", data, Constants.reasonHeader(reason));
114
+ }
115
+ /**
116
+ * Deletes an auto moderation rule for a guild
117
+ * @since 0.7.0
118
+ * @param guildId id of the guild
119
+ * @param ruleId id of the rule
120
+ * @param reason Reason for deleting the rule
121
+ * @returns Resolves the Promise on successful execution
122
+ *
123
+ * | Permissions needed | Condition |
124
+ * |--------------------|-----------|
125
+ * | MANAGE_GUILD | always |
126
+ *
127
+ * @example
128
+ * const client = new SnowTransfer("TOKEN")
129
+ * client.autoMod.deleteAutoModerationRule("guild id", "rule id", "was useless")
130
+ */
131
+ async deleteAutoModerationRule(guildId, ruleId, reason) {
132
+ return this.requestHandler.request(Endpoints.GUILD_AUTO_MOD_RULE(guildId, ruleId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
133
+ }
134
+ }
135
+ module.exports = AutoModerationMethods;