snowtransfer 0.3.0
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/LICENSE.md +21 -0
- package/README.md +46 -0
- package/dist/Constants.d.ts +8 -0
- package/dist/Constants.js +8 -0
- package/dist/Endpoints.d.ts +89 -0
- package/dist/Endpoints.js +99 -0
- package/dist/Ratelimiter.d.ts +39 -0
- package/dist/Ratelimiter.js +69 -0
- package/dist/RequestHandler.d.ts +112 -0
- package/dist/RequestHandler.js +238 -0
- package/dist/SnowTransfer.d.ts +51 -0
- package/dist/SnowTransfer.js +56 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/dist/methods/AuditLog.d.ts +45 -0
- package/dist/methods/AuditLog.js +35 -0
- package/dist/methods/Bots.d.ts +40 -0
- package/dist/methods/Bots.js +46 -0
- package/dist/methods/Channels.d.ts +749 -0
- package/dist/methods/Channels.js +685 -0
- package/dist/methods/GuildAssets.d.ts +191 -0
- package/dist/methods/GuildAssets.js +172 -0
- package/dist/methods/GuildTemplate.d.ts +57 -0
- package/dist/methods/GuildTemplate.js +68 -0
- package/dist/methods/Guilds.d.ts +733 -0
- package/dist/methods/Guilds.js +598 -0
- package/dist/methods/Interactions.d.ts +221 -0
- package/dist/methods/Interactions.js +262 -0
- package/dist/methods/Invites.d.ts +37 -0
- package/dist/methods/Invites.js +44 -0
- package/dist/methods/StageInstance.d.ts +64 -0
- package/dist/methods/StageInstance.js +73 -0
- package/dist/methods/Users.d.ts +76 -0
- package/dist/methods/Users.js +93 -0
- package/dist/methods/Voices.d.ts +21 -0
- package/dist/methods/Voices.js +29 -0
- package/dist/methods/Webhooks.d.ts +288 -0
- package/dist/methods/Webhooks.js +222 -0
- package/dist/ratelimitBuckets/LocalBucket.d.ts +58 -0
- package/dist/ratelimitBuckets/LocalBucket.js +77 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const Endpoints_1 = __importDefault(require("../Endpoints"));
|
|
6
|
+
/**
|
|
7
|
+
* Methods for interacting with Guilds
|
|
8
|
+
*/
|
|
9
|
+
class GuildMethods {
|
|
10
|
+
/**
|
|
11
|
+
* Create a new Guild 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.guild.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
|
+
* Create a new Guild, **limited to 10 guilds (you may create more if you are whitelisted)**
|
|
23
|
+
* Check the [discord docs](https://discord.com/developers/docs/resources/guild#create-guild) for more infos
|
|
24
|
+
* @param {object} data data
|
|
25
|
+
* @returns [Guild](https://discord.com/developers/docs/resources/guild#guild-object)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Creates a simple guild with the name "Demo Guild"
|
|
29
|
+
* let client = new SnowTransfer('TOKEN')
|
|
30
|
+
* let guildData = {
|
|
31
|
+
* name: 'Demo Guild'
|
|
32
|
+
* }
|
|
33
|
+
* client.guild.createGuild(guildData)
|
|
34
|
+
*/
|
|
35
|
+
async createGuild(data) {
|
|
36
|
+
return this.requestHandler.request(Endpoints_1.default.GUILDS, "post", "json", data);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a guild via Id
|
|
40
|
+
*
|
|
41
|
+
* **Your bot has to be a member of the guild for this function to work**
|
|
42
|
+
* @param guildId Id of the guild
|
|
43
|
+
* @returns [Guild object](https://discord.com/developers/docs/resources/guild#guild-object)
|
|
44
|
+
*/
|
|
45
|
+
async getGuild(guildId, options) {
|
|
46
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD(guildId), "get", "json", options);
|
|
47
|
+
}
|
|
48
|
+
async getGuildPreview(guildId) {
|
|
49
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_PREVIEW(guildId), "get", "json");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Update a guild
|
|
53
|
+
* @param guildId Id of the guild
|
|
54
|
+
* @param data data
|
|
55
|
+
* @returns [Guild object](https://discord.com/developers/docs/resources/guild#guild-object)
|
|
56
|
+
*
|
|
57
|
+
* | Permissions needed | Condition |
|
|
58
|
+
* |--------------------|-----------|
|
|
59
|
+
* | MANAGE_GUILD | always |
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // Update the name of a guild to "Nice Guild"
|
|
63
|
+
* let client = new SnowTransfer('TOKEN')
|
|
64
|
+
* let guildData = {
|
|
65
|
+
* name: 'Nice Guild'
|
|
66
|
+
* }
|
|
67
|
+
* client.guild.updateGuild('guild Id', guildData)
|
|
68
|
+
*/
|
|
69
|
+
async updateGuild(guildId, data) {
|
|
70
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD(guildId), "patch", "json", data);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Delete a guild
|
|
74
|
+
*
|
|
75
|
+
* **Your bot has to be the owner of the guild to do this**
|
|
76
|
+
*
|
|
77
|
+
* **This action is irreversible, so use it with caution!**
|
|
78
|
+
* @param guildId Id of the guild
|
|
79
|
+
* @returns Resolves the Promise on successful execution
|
|
80
|
+
*/
|
|
81
|
+
async deleteGuild(guildId) {
|
|
82
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD(guildId), "delete", "json");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get a list of channels for a guild
|
|
86
|
+
* @param guildId Id of the guild
|
|
87
|
+
* @returns list of [channels](https://discord.com/developers/docs/resources/channel#channel-object-channel-structure)
|
|
88
|
+
*/
|
|
89
|
+
async getGuildChannels(guildId) {
|
|
90
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_CHANNELS(guildId), "get", "json");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a channel within a guild
|
|
94
|
+
* @param guildId Id of the guild
|
|
95
|
+
* @param data channel properties
|
|
96
|
+
* @returns [channel object](https://discord.com/developers/docs/resources/channel#channel-object-channel-structure)
|
|
97
|
+
*
|
|
98
|
+
* | Permissions needed | Condition |
|
|
99
|
+
* |--------------------|-----------------------------------------------|
|
|
100
|
+
* | MANAGE_CHANNELS | always |
|
|
101
|
+
* | ADMINISTRATOR | setting MANAGE_ROLES in permission_overwrites |
|
|
102
|
+
*/
|
|
103
|
+
async createGuildChannel(guildId, data) {
|
|
104
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_CHANNELS(guildId), "post", "json", data);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Batch update the positions of channels
|
|
108
|
+
* @param guildId Id of the guild
|
|
109
|
+
* @returns Resolves the Promise on successful execution
|
|
110
|
+
*/
|
|
111
|
+
async updateChannelPositions(guildId, data) {
|
|
112
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_CHANNELS(guildId), "patch", "json", data);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns all active threads in the guild, including public and private threads. Threads are ordered by their `id`, in descending order
|
|
116
|
+
* @param guildId Id of the guild
|
|
117
|
+
* @returns All active threads and members the current user has access to.
|
|
118
|
+
*/
|
|
119
|
+
async listActiveThreads(guildId) {
|
|
120
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_THREADS_ACTIVE(guildId), "get", "json");
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get a guild member via Id
|
|
124
|
+
* @param guildId Id of the guild
|
|
125
|
+
* @param memberId Id of the guild member
|
|
126
|
+
* @returns [guild member](https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure)
|
|
127
|
+
*/
|
|
128
|
+
async getGuildMember(guildId, memberId) {
|
|
129
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER(guildId, memberId), "get", "json");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get a list of guild members
|
|
133
|
+
* @param guildId Id of the guild
|
|
134
|
+
* @param data query data
|
|
135
|
+
* @returns list of [guild members](https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure)
|
|
136
|
+
*/
|
|
137
|
+
async getGuildMembers(guildId, data = {}) {
|
|
138
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBERS(guildId), "get", "json", data);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get a list of guild members that match a query
|
|
142
|
+
* @param guildId Id of the guild
|
|
143
|
+
* @param options query data
|
|
144
|
+
* @returns list of [guild members](https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure)
|
|
145
|
+
*/
|
|
146
|
+
async searchGuildMembers(guildId, options) {
|
|
147
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBERS_SEARCH(guildId), "get", "json", options);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Add a guild member to a guild via oauth2 access token
|
|
151
|
+
*
|
|
152
|
+
* **You need the oauth2 `guilds.join` scope granted to the access_token**
|
|
153
|
+
*
|
|
154
|
+
*
|
|
155
|
+
* **Your bot has to be a member of the guild you want to add the user to**
|
|
156
|
+
*
|
|
157
|
+
* @param guildId Id of the guild
|
|
158
|
+
* @param memberId Id of the guild member
|
|
159
|
+
* @param data object containing the needed request data
|
|
160
|
+
* @returns [guild member](https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure)
|
|
161
|
+
*
|
|
162
|
+
* | Permissions needed | Condition |
|
|
163
|
+
* |-----------------------|-----------|
|
|
164
|
+
* | CREATE_INSTANT_INVITE | always |
|
|
165
|
+
*
|
|
166
|
+
* | OAUTH2 Scopes |
|
|
167
|
+
* |---------------|
|
|
168
|
+
* | guilds.join |
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* // add a user to a server
|
|
172
|
+
* let client = new SnowTransfer('TOKEN')
|
|
173
|
+
* let memberData = {
|
|
174
|
+
* access_token: 'access token of a user with the guilds.join scope'
|
|
175
|
+
* }
|
|
176
|
+
* client.guild.addGuildMember('guildId', 'memberId', memberData)
|
|
177
|
+
*/
|
|
178
|
+
async addGuildMember(guildId, memberId, data) {
|
|
179
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER(guildId, memberId), "put", "json", data);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Update properties of a guild member
|
|
183
|
+
*
|
|
184
|
+
* **Check the table below to make sure you have the right permissions for the types of updates**
|
|
185
|
+
*
|
|
186
|
+
* **Make sure that your bot has `CONNECT` and `MOVE_MEMBERS` on the channel you want to move the member to**
|
|
187
|
+
* @param guildId Id of the guild
|
|
188
|
+
* @param memberId Id of the guild member
|
|
189
|
+
* @param data Updated properties
|
|
190
|
+
* @returns Resolves the Promise on successful execution
|
|
191
|
+
*
|
|
192
|
+
* | Permissions needed | Condition |
|
|
193
|
+
* |--------------------|--------------|
|
|
194
|
+
* | MANAGE_NICKNAMES | Nick Updates |
|
|
195
|
+
* | MANAGE_ROLES | Role Updates |
|
|
196
|
+
* | MUTE_MEMBERS | Mute Updates |
|
|
197
|
+
* | DEAFEN_MEMBERS | Deaf Updates |
|
|
198
|
+
* | MOVE_MEMBERS | Voice Move |
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Reset the nickname of a guild member
|
|
202
|
+
* let client = new SnowTransfer('TOKEN')
|
|
203
|
+
* let memberData = {
|
|
204
|
+
* nick: "" // You can reset nicknames by providing an empty string as the value of data.nick
|
|
205
|
+
* }
|
|
206
|
+
* client.guild.updateGuildMember('guild Id', 'memberId', memberData)
|
|
207
|
+
*/
|
|
208
|
+
async updateGuildMember(guildId, memberId, data) {
|
|
209
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER(guildId, memberId), "patch", "json", data);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Update the nick of the current user
|
|
213
|
+
* @param guildId Id of the guild
|
|
214
|
+
* @param data object with a nick property
|
|
215
|
+
* @returns Resolves the Promise on successful execution
|
|
216
|
+
*
|
|
217
|
+
* | Permissions needed | Condition |
|
|
218
|
+
* |--------------------|-----------|
|
|
219
|
+
* | CHANGE_NICKNAME | always |
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* // change nick of bot to "Nice Nick"
|
|
223
|
+
* let client = new SnowTransfer('TOKEN')
|
|
224
|
+
* let nickData = {
|
|
225
|
+
* nick: 'Nice Nick'
|
|
226
|
+
* }
|
|
227
|
+
* client.guild.updateSelf('guildId', nickData)
|
|
228
|
+
*/
|
|
229
|
+
async updateSelf(guildId, data) {
|
|
230
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER_NICK(guildId, "@me"), "patch", "json", data);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Add a role to a guild member
|
|
234
|
+
* @param guildId Id of the guild
|
|
235
|
+
* @param memberId Id of the guild member
|
|
236
|
+
* @param roleId Id of the role
|
|
237
|
+
* @param data object with reason property
|
|
238
|
+
* @returns Resolves the Promise on successful execution
|
|
239
|
+
*
|
|
240
|
+
* | Permissions needed | Condition |
|
|
241
|
+
* |--------------------|-----------|
|
|
242
|
+
* | MANAGE_ROLES | always |
|
|
243
|
+
*/
|
|
244
|
+
async addGuildMemberRole(guildId, memberId, roleId, data) {
|
|
245
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER_ROLE(guildId, memberId, roleId), "put", "json", data);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Remove a role from a guild member
|
|
249
|
+
* @param guildId Id of the guild
|
|
250
|
+
* @param memberId Id of the guild member
|
|
251
|
+
* @param roleId Id of the role
|
|
252
|
+
* @param data object with reason property
|
|
253
|
+
* @returns Resolves the Promise on successful execution
|
|
254
|
+
*
|
|
255
|
+
* | Permissions needed | Condition |
|
|
256
|
+
* |--------------------|-----------|
|
|
257
|
+
* | MANAGE_ROLES | always |
|
|
258
|
+
*/
|
|
259
|
+
async removeGuildMemberRole(guildId, memberId, roleId, data) {
|
|
260
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER_ROLE(guildId, memberId, roleId), "delete", "json", data);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Remove a guild member (aka kick them)
|
|
264
|
+
* @param guildId Id of the guild
|
|
265
|
+
* @param memberId Id of the guild member
|
|
266
|
+
* @param data object with reason property
|
|
267
|
+
* @returns Resolves the Promise on successful execution
|
|
268
|
+
*
|
|
269
|
+
* | Permissions needed | Condition |
|
|
270
|
+
* |--------------------|-----------|
|
|
271
|
+
* | KICK_MEMBERS | always |
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* // Kick a member with a reason of "spam"
|
|
275
|
+
* let client = new SnowTransfer('TOKEN')
|
|
276
|
+
* let kickData = {
|
|
277
|
+
* reason: 'spam'
|
|
278
|
+
* }
|
|
279
|
+
* client.guild.removeGuildMember('guild Id', 'memberId', kickData)
|
|
280
|
+
*/
|
|
281
|
+
async removeGuildMember(guildId, memberId, data) {
|
|
282
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_MEMBER(guildId, memberId), "delete", "json", data);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Get bans of a guild
|
|
286
|
+
* @param guildId Id of the guild
|
|
287
|
+
* @returns List of [bans](https://discord.com/developers/docs/resources/guild#ban-object-ban-structure)
|
|
288
|
+
*
|
|
289
|
+
* | Permissions needed | Condition |
|
|
290
|
+
* |--------------------|-----------|
|
|
291
|
+
* | BAN_MEMBERS | always |
|
|
292
|
+
*/
|
|
293
|
+
async getGuildBans(guildId) {
|
|
294
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_BANS(guildId), "get", "json");
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Ban a guild member
|
|
298
|
+
* @param guildId Id of the guild
|
|
299
|
+
* @param memberId Id of the guild member
|
|
300
|
+
* @param data object with a reason and a delete-message-days property
|
|
301
|
+
* @returns Resolves the Promise on successful execution
|
|
302
|
+
*
|
|
303
|
+
* | Permissions needed | Condition |
|
|
304
|
+
* |--------------------|-----------|
|
|
305
|
+
* | BAN_MEMBERS | always |
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* // Ban a user with a reason and delete the last 2 days of their messages
|
|
309
|
+
* let client = new SnowTransfer('TOKEN')
|
|
310
|
+
* let banData = {
|
|
311
|
+
* reason: 'Memes were not good enough',
|
|
312
|
+
* "delete_message_days":2
|
|
313
|
+
* }
|
|
314
|
+
* client.guild.createGuildBan('guild Id', 'memberId', banData)
|
|
315
|
+
*/
|
|
316
|
+
async createGuildBan(guildId, memberId, data) {
|
|
317
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_BAN(guildId, memberId), "put", "json", data);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Remove a ban of a user
|
|
321
|
+
* @param guildId Id of the guild
|
|
322
|
+
* @param memberId Id of the guild member
|
|
323
|
+
* @param data object with a reason property
|
|
324
|
+
* @returns Resolves the Promise on successful execution
|
|
325
|
+
*
|
|
326
|
+
* | Permissions needed | Condition |
|
|
327
|
+
* |--------------------|-----------|
|
|
328
|
+
* | BAN_MEMBERS | always |
|
|
329
|
+
*/
|
|
330
|
+
async removeGuildBan(guildId, memberId, data) {
|
|
331
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_BAN(guildId, memberId), "delete", "json", data);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get a list of roles for a guild
|
|
335
|
+
* @param guildId Id of the guild
|
|
336
|
+
* @returns array of [roles](https://discord.com/developers/docs/topics/permissions#role-object)
|
|
337
|
+
*
|
|
338
|
+
* | Permissions needed | Condition |
|
|
339
|
+
* |--------------------|-----------|
|
|
340
|
+
* | MANAGE_ROLES | always |
|
|
341
|
+
*/
|
|
342
|
+
async getGuildRoles(guildId) {
|
|
343
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_ROLES(guildId), "get", "json");
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Create a new Role
|
|
347
|
+
* @param guildId Id of the guild
|
|
348
|
+
* @param data data with role properties
|
|
349
|
+
* @returns [role](https://discord.com/developers/docs/resources/channel#channel-object-channel-structure)
|
|
350
|
+
*
|
|
351
|
+
* | Permissions needed | Condition |
|
|
352
|
+
* |--------------------|-----------|
|
|
353
|
+
* | MANAGE_ROLES | always |
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* // Create a role with the name "Nice Role" and a color of a soft blue
|
|
357
|
+
* let client = new SnowTransfer('TOKEN')
|
|
358
|
+
* let roleData = {
|
|
359
|
+
* name: 'Nice Role',
|
|
360
|
+
* color: 0x7c7cf8
|
|
361
|
+
* }
|
|
362
|
+
* client.guild.createGuildRole('guild Id', roleData)
|
|
363
|
+
*/
|
|
364
|
+
async createGuildRole(guildId, data) {
|
|
365
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_ROLES(guildId), "post", "json", data);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Modify the positions of a role or multiple roles
|
|
369
|
+
* @param guildId Id of the guild
|
|
370
|
+
* @param data Role data to update
|
|
371
|
+
* @returns array of [roles](https://discord.com/developers/docs/topics/permissions#role-object)
|
|
372
|
+
*
|
|
373
|
+
* | Permissions needed | Condition |
|
|
374
|
+
* |--------------------|-----------|
|
|
375
|
+
* | MANAGE_ROLES | always |
|
|
376
|
+
*/
|
|
377
|
+
async updateGuildRolePositions(guildId, data) {
|
|
378
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_ROLES(guildId), Array.isArray(data) ? "put" : "patch", "json", data);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Update a guild role
|
|
382
|
+
* @param guildId Id of the guild
|
|
383
|
+
* @param roleId Id of the role
|
|
384
|
+
* @param data updated properties of the role
|
|
385
|
+
* @returns [Updated Role](https://discord.com/developers/docs/topics/permissions#role-object)
|
|
386
|
+
*
|
|
387
|
+
* | Permissions needed | Condition |
|
|
388
|
+
* |--------------------|-----------|
|
|
389
|
+
* | MANAGE_ROLES | always |
|
|
390
|
+
*/
|
|
391
|
+
async updateGuildRole(guildId, roleId, data) {
|
|
392
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_ROLE(guildId, roleId), "patch", "json", data);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Delete a role from the guild
|
|
396
|
+
* @param guildId Id of the guild
|
|
397
|
+
* @param roleId Id of the role
|
|
398
|
+
* @returns Resolves the Promise on successful execution
|
|
399
|
+
*
|
|
400
|
+
* | Permissions needed | Condition |
|
|
401
|
+
* |--------------------|-----------|
|
|
402
|
+
* | MANAGE_ROLES | always |
|
|
403
|
+
*/
|
|
404
|
+
async removeGuildRole(guildId, roleId) {
|
|
405
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_ROLE(guildId, roleId), "delete", "json");
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get the amount of members that would be pruned when a prune with the passed amount of days would be started
|
|
409
|
+
* @param guildId Id of the guild
|
|
410
|
+
* @param data Object with a days property
|
|
411
|
+
* @returns Object with a "pruned" key indicating the amount of members that would be pruned
|
|
412
|
+
*
|
|
413
|
+
* | Permissions needed | Condition |
|
|
414
|
+
* |--------------------|-----------|
|
|
415
|
+
* | KICK_MEMBERS | always |
|
|
416
|
+
*/
|
|
417
|
+
async getGuildPruneCount(guildId, data) {
|
|
418
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_PRUNE(guildId), "get", "json", data);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Start a prune
|
|
422
|
+
* @param guildId Id of the guild
|
|
423
|
+
* @param data Object with a days property
|
|
424
|
+
* @returns Object with a "pruned" key indicating the amount of members that were pruned
|
|
425
|
+
*
|
|
426
|
+
* | Permissions needed | Condition |
|
|
427
|
+
* |--------------------|-----------|
|
|
428
|
+
* | KICK_MEMBERS | always |
|
|
429
|
+
*/
|
|
430
|
+
async startGuildPrune(guildId, data) {
|
|
431
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_PRUNE(guildId), "post", "json", data);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Get a list of voice regions for the guild, includes vip-regions unlike voice.getVoiceRegions
|
|
435
|
+
* @param guildId Id of the guild
|
|
436
|
+
* @returns List of [voice regions](https://discord.com/developers/docs/resources/voice#voice-region-object)
|
|
437
|
+
*/
|
|
438
|
+
async getGuildVoiceRegions(guildId) {
|
|
439
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_VOICE_REGIONS(guildId), "get", "json");
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Get invites for a guild
|
|
443
|
+
* @param guildId Id of the guild
|
|
444
|
+
* @returns List of [invites](https://discord.com/developers/docs/resources/invite#invite-object) (with metadata)
|
|
445
|
+
*
|
|
446
|
+
* | Permissions needed | Condition |
|
|
447
|
+
* |--------------------|-----------|
|
|
448
|
+
* | MANAGE_GUILD | always |
|
|
449
|
+
*/
|
|
450
|
+
async getGuildInvites(guildId) {
|
|
451
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_INVITES(guildId), "get", "json");
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Get integrations for a guild
|
|
455
|
+
* @param guildId Id of the guild
|
|
456
|
+
* @returns List of [integration objects](https://discord.com/developers/docs/resources/guild#integration-object)
|
|
457
|
+
*
|
|
458
|
+
* | Permissions needed | Condition |
|
|
459
|
+
* |--------------------|-----------|
|
|
460
|
+
* | MANAGE_GUILD | always |
|
|
461
|
+
*/
|
|
462
|
+
async getGuildIntegrations(guildId) {
|
|
463
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_INTEGRATIONS(guildId), "get", "json");
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Attach a integration object from the user to the guild
|
|
467
|
+
* @param guildId Id of the guild
|
|
468
|
+
* @param data Integration object with id and type properties
|
|
469
|
+
* @returns Resolves the Promise on successful execution
|
|
470
|
+
*
|
|
471
|
+
* | Permissions needed | Condition |
|
|
472
|
+
* |--------------------|-----------|
|
|
473
|
+
* | MANAGE_GUILD | always |
|
|
474
|
+
*/
|
|
475
|
+
async createGuildIntegration(guildId, data) {
|
|
476
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_INTEGRATIONS(guildId), "post", "json", data);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Update behaviour and settings of an [integration object](https://discord.com/developers/docs/resources/guild#integration-object)
|
|
480
|
+
* @param guildId Id of the guild
|
|
481
|
+
* @param integrationId Id of the integration
|
|
482
|
+
* @returns Resolves the Promise on successful execution
|
|
483
|
+
*
|
|
484
|
+
* | Permissions needed | Condition |
|
|
485
|
+
* |--------------------|-----------|
|
|
486
|
+
* | MANAGE_GUILD | always |
|
|
487
|
+
*/
|
|
488
|
+
async updateGuildIntegration(guildId, integrationId, data) {
|
|
489
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_INTEGRATION(guildId, integrationId), "patch", "json", data);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Delete a guild integratiom
|
|
493
|
+
* @param guildId Id of the guild
|
|
494
|
+
* @param integrationId Id of the integration
|
|
495
|
+
* @returns Resolves the Promise on successful execution
|
|
496
|
+
*
|
|
497
|
+
* | Permissions needed | Condition |
|
|
498
|
+
* |--------------------|-----------|
|
|
499
|
+
* | MANAGE_GUILD | always |
|
|
500
|
+
*/
|
|
501
|
+
async removeGuildIntegration(guildId, integrationId) {
|
|
502
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_INTEGRATION(guildId, integrationId), "delete", "json");
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Gets a guild widget object
|
|
506
|
+
* @param guildId Id of the guild
|
|
507
|
+
* @returns [Guild Widget](https://discord.com/developers/docs/resources/guild#guild-widget-object)
|
|
508
|
+
*/
|
|
509
|
+
async getGuildWidget(guildId) {
|
|
510
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_WIDGET(guildId), "get", "json");
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Get a guild widget settings object
|
|
514
|
+
* @param guildId Id of the guild
|
|
515
|
+
* @returns [Guild Widget](https://discord.com/developers/docs/resources/guild#guild-widget-object)
|
|
516
|
+
*
|
|
517
|
+
* | Permissions needed | Condition |
|
|
518
|
+
* |--------------------|-----------|
|
|
519
|
+
* | MANAGE_GUILD | always |
|
|
520
|
+
*/
|
|
521
|
+
async getGuildWidgetSettings(guildId) {
|
|
522
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_WIDGET_SETTINGS(guildId), "get", "json");
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Update a guild widget settings object
|
|
526
|
+
* @param guildId Id of the guild
|
|
527
|
+
* @param data basic data of widget settings
|
|
528
|
+
* @returns [Guild Widget](https://discord.com/developers/docs/resources/guild#guild-widget-object)
|
|
529
|
+
*
|
|
530
|
+
* | Permissions needed | Condition |
|
|
531
|
+
* |--------------------|-----------|
|
|
532
|
+
* | MANAGE_GUILD | always |
|
|
533
|
+
*/
|
|
534
|
+
async updateGuildWidgetSettings(guildId, data) {
|
|
535
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_WIDGET_SETTINGS(guildId), "patch", "json", data);
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Get a guild's vanity URL code
|
|
539
|
+
* @param guildId Id of the guild
|
|
540
|
+
* @returns partial [invite object](https://discord.com/developers/docs/resources/guild#get-guild-vanity-url-example-partial-invite-object)
|
|
541
|
+
*
|
|
542
|
+
* | Permissions needed | Condition |
|
|
543
|
+
* |--------------------|-----------|
|
|
544
|
+
* | MANAGE_GUILD | always |
|
|
545
|
+
*/
|
|
546
|
+
async getGuildVanityURL(guildId) {
|
|
547
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_VANITY(guildId), "get", "json");
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Get a guild's welcome screen object
|
|
551
|
+
* @param guildId Id of the guild
|
|
552
|
+
* @returns [Guild Welcome Screen](https://discord.com/developers/docs/resources/guild#welcome-screen-object)
|
|
553
|
+
*/
|
|
554
|
+
async getGuildWelcomeScreen(guildId) {
|
|
555
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_WELCOME_SCREEN(guildId), "get", "json");
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Update a guild welcome screen object
|
|
559
|
+
* @param guildId Id of guild
|
|
560
|
+
* @param data Welcome screen data
|
|
561
|
+
* @returns [Guild Welcome Screen](https://discord.com/developers/docs/resources/guild#welcome-screen-object)
|
|
562
|
+
*
|
|
563
|
+
* | Permissions needed | Condition |
|
|
564
|
+
* |--------------------|-----------|
|
|
565
|
+
* | MANAGE_GUILD | always |
|
|
566
|
+
*/
|
|
567
|
+
async editGuildWelcomeScreen(guildId, data) {
|
|
568
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_WELCOME_SCREEN(guildId), "patch", "json", data);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Updates the current user's voice state in a stage channel
|
|
572
|
+
* @param guildId Id of the guild
|
|
573
|
+
* @param data Data of the voice state
|
|
574
|
+
* @returns Resolves the Promise on successful execution
|
|
575
|
+
*
|
|
576
|
+
* | Permissions needed | Condition |
|
|
577
|
+
* |--------------------|-------------------------------------|
|
|
578
|
+
* | MUTE_MEMBERS | when trying to un-suppress yourself |
|
|
579
|
+
* | REQUEST_TO_SPEAK | when trying to request to speak |
|
|
580
|
+
*/
|
|
581
|
+
updateCurrentUserVoiceState(guildId, data) {
|
|
582
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_VOICE_STATE_USER(guildId, "@me"), "patch", "json", data);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Updates a user's voice state in a stage channel
|
|
586
|
+
* @param guildId Id of the guild
|
|
587
|
+
* @param data Data of the voice state
|
|
588
|
+
* @returns Resolves the Promise on successful execution
|
|
589
|
+
*
|
|
590
|
+
* | Permissions needed | Condition |
|
|
591
|
+
* |--------------------|-------------------------------------|
|
|
592
|
+
* | MUTE_MEMBERS | when trying to suppress/un-suppress |
|
|
593
|
+
*/
|
|
594
|
+
updateUserVoiceState(guildId, userId, data) {
|
|
595
|
+
return this.requestHandler.request(Endpoints_1.default.GUILD_VOICE_STATE_USER(guildId, userId), "patch", "json", data);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
module.exports = GuildMethods;
|