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.
- package/CHANGELOG.md +29 -0
- package/dist/Constants.d.ts +59 -0
- package/dist/Constants.js +123 -0
- package/dist/Endpoints.d.ts +120 -0
- package/dist/Endpoints.js +121 -0
- package/dist/RequestHandler.d.ts +258 -0
- package/dist/RequestHandler.js +629 -0
- package/dist/SnowTransfer.d.ts +70 -0
- package/dist/SnowTransfer.js +105 -0
- package/dist/StateMachine.d.ts +89 -0
- package/dist/StateMachine.js +208 -0
- package/dist/StateMachineGraph.d.ts +3 -0
- package/dist/StateMachineGraph.js +23 -0
- package/dist/Types.d.ts +76 -0
- package/dist/Types.js +2 -0
- package/dist/index.d.ts +25 -718
- package/dist/index.js +63 -44
- package/dist/methods/Assets.d.ts +290 -0
- package/dist/methods/Assets.js +326 -0
- package/dist/methods/AuditLog.d.ts +40 -0
- package/dist/methods/AuditLog.js +44 -0
- package/dist/methods/AutoModeration.d.ts +122 -0
- package/dist/methods/AutoModeration.js +135 -0
- package/dist/methods/Bot.d.ts +65 -0
- package/dist/methods/Bot.js +75 -0
- package/dist/methods/Channel.d.ts +866 -0
- package/dist/methods/Channel.js +982 -0
- package/dist/methods/Entitlements.d.ts +87 -0
- package/dist/methods/Entitlements.js +99 -0
- package/dist/methods/Guild.d.ts +722 -0
- package/dist/methods/Guild.js +785 -0
- package/dist/methods/GuildScheduledEvent.d.ts +138 -0
- package/dist/methods/GuildScheduledEvent.js +155 -0
- package/dist/methods/GuildTemplate.d.ts +110 -0
- package/dist/methods/GuildTemplate.js +124 -0
- package/dist/methods/Interaction.d.ts +339 -0
- package/dist/methods/Interaction.js +359 -0
- package/dist/methods/Invite.d.ts +81 -0
- package/dist/methods/Invite.js +107 -0
- package/dist/methods/Sku.d.ts +58 -0
- package/dist/methods/Sku.js +66 -0
- package/dist/methods/StageInstance.d.ts +86 -0
- package/dist/methods/StageInstance.js +97 -0
- package/dist/methods/User.d.ts +167 -0
- package/dist/methods/User.js +184 -0
- package/dist/methods/Voice.d.ts +44 -0
- package/dist/methods/Voice.js +52 -0
- package/dist/methods/Webhook.d.ts +265 -0
- package/dist/methods/Webhook.js +256 -0
- package/dist/tokenless.d.ts +19 -0
- package/dist/tokenless.js +31 -0
- package/package.json +9 -9
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { RequestHandler } from "../RequestHandler";
|
|
2
|
+
import type { RESTDeleteAPIGuildScheduledEventResult, RESTGetAPIGuildScheduledEventResult, RESTGetAPIGuildScheduledEventUsersQuery, RESTGetAPIGuildScheduledEventUsersResult, RESTGetAPIGuildScheduledEventsResult, RESTPatchAPIGuildScheduledEventJSONBody, RESTPatchAPIGuildScheduledEventResult, RESTPostAPIGuildScheduledEventJSONBody, RESTPostAPIGuildScheduledEventResult } from "discord-api-types/v10";
|
|
3
|
+
/**
|
|
4
|
+
* Methods for interacting with Guild Scheduled Events
|
|
5
|
+
* @since 0.3.6
|
|
6
|
+
*/
|
|
7
|
+
declare class GuildScheduledEventMethods {
|
|
8
|
+
readonly requestHandler: RequestHandler;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new Guild Scheduled Event 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.guildScheduledEvent.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 scheduled events for a guild
|
|
20
|
+
* @since 0.3.6
|
|
21
|
+
* @param guildId The Id of the guild
|
|
22
|
+
* @param withCounts Include number of users subscribed to each event
|
|
23
|
+
* @returns An array of [guild scheduled events](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const client = new SnowTransfer("TOKEN")
|
|
27
|
+
* const events = await client.guildScheduledEvent.listGuildScheduledEvents(guildId)
|
|
28
|
+
*/
|
|
29
|
+
listGuildScheduledEvents(guildId: string, withCounts?: boolean): Promise<RESTGetAPIGuildScheduledEventsResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a scheduled event for a guild
|
|
32
|
+
* @since 0.3.6
|
|
33
|
+
* @param guildId The Id of the guild
|
|
34
|
+
* @param data Data for the new scheduled event
|
|
35
|
+
* @param reason Reason for creating the scheduled event
|
|
36
|
+
* @returns A [scheduled event](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
37
|
+
*
|
|
38
|
+
* | Permissions needed | Condition |
|
|
39
|
+
* |--------------------|----------------------------------|
|
|
40
|
+
* | MANAGE_EVENTS | always |
|
|
41
|
+
* | MANAGE_CHANNELS | If entity_type is STAGE_INSTANCE |
|
|
42
|
+
* | MUTE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
43
|
+
* | MOVE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
44
|
+
* | VIEW_CHANNEL | If entity_type is VOICE |
|
|
45
|
+
* | CONNECT | If entity_type is VOICE |
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const client = new SnowTransfer("TOKEN")
|
|
49
|
+
* const eventData = {
|
|
50
|
+
* name: "My event!",
|
|
51
|
+
* entity_type: 1,
|
|
52
|
+
* start_time: "2020-01-01T00:00:00Z",
|
|
53
|
+
* privacy_level: 1
|
|
54
|
+
* }
|
|
55
|
+
* const event = await client.guildScheduledEvent.createGuildScheduledEvent(guildId, eventData)
|
|
56
|
+
*/
|
|
57
|
+
createGuildScheduledEvent(guildId: string, data: RESTPostAPIGuildScheduledEventJSONBody, reason?: string): Promise<RESTPostAPIGuildScheduledEventResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Get a specific scheduled event for a guild
|
|
60
|
+
* @since 0.3.6
|
|
61
|
+
* @param guildId The Id of the guild
|
|
62
|
+
* @param eventId The Id of the event
|
|
63
|
+
* @param withCounts Include number of users subscribed to this event
|
|
64
|
+
* @returns A [scheduled event](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
65
|
+
*
|
|
66
|
+
* | Permissions needed | Condition |
|
|
67
|
+
* |--------------------|-------------------------------------------|
|
|
68
|
+
* | VIEW_CHANNEL | if entity_type is STAGE_INSTANCE or VOICE |
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const client = new SnowTransfer("TOKEN")
|
|
72
|
+
* const event = await client.guildScheduledEvent.getGuildScheduledEvent(guildId, eventId)
|
|
73
|
+
*/
|
|
74
|
+
getGuildScheduledEvent(guildId: string, eventId: string, withCounts?: boolean): Promise<RESTGetAPIGuildScheduledEventResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Edit the details of a scheduled event for a guild
|
|
77
|
+
* @since 0.3.6
|
|
78
|
+
* @param guildId The Id of the guild
|
|
79
|
+
* @param eventId The Id of the event
|
|
80
|
+
* @param data Edited scheduled event data
|
|
81
|
+
* @param reason Reason for editing the scheduled event
|
|
82
|
+
* @returns A [scheduled event](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
83
|
+
*
|
|
84
|
+
* | Permissions needed | Condition |
|
|
85
|
+
* |--------------------|----------------------------------|
|
|
86
|
+
* | MANAGE_EVENTS | always |
|
|
87
|
+
* | MANAGE_CHANNELS | If entity_type is STAGE_INSTANCE |
|
|
88
|
+
* | MUTE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
89
|
+
* | MOVE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
90
|
+
* | VIEW_CHANNEL | If entity_type is VOICE |
|
|
91
|
+
* | CONNECT | If entity_type is VOICE |
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* // Updates a scheduled event to be an external event that will take place in Brazil and end in 2025
|
|
95
|
+
* const client = new SnowTransfer("TOKEN")
|
|
96
|
+
* const event = await client.guildScheduledEvent.editGuildScheduledEvent(guildId, eventId, { entity_type: 3, channel_id: null, entity_metadata: { location: "Brazil" }, scheduled_end_time: "2025-01-01T00:00:00.000Z" })
|
|
97
|
+
*/
|
|
98
|
+
editGuildScheduledEvent(guildId: string, eventId: string, data: RESTPatchAPIGuildScheduledEventJSONBody, reason?: string): Promise<RESTPatchAPIGuildScheduledEventResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Delete a specific scheduled event for a guild
|
|
101
|
+
* @since 0.3.6
|
|
102
|
+
* @param guildId The Id of the guild
|
|
103
|
+
* @param eventId The Id of the event
|
|
104
|
+
* @returns Resolves the promise on successful execution
|
|
105
|
+
*
|
|
106
|
+
* | Permissions needed | Condition |
|
|
107
|
+
* |--------------------|----------------------------------|
|
|
108
|
+
* | MANAGE_EVENTS | always |
|
|
109
|
+
* | MANAGE_CHANNELS | If entity_type is STAGE_INSTANCE |
|
|
110
|
+
* | MUTE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
111
|
+
* | MOVE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
112
|
+
* | VIEW_CHANNEL | If entity_type is VOICE |
|
|
113
|
+
* | CONNECT | If entity_type is VOICE |
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const client = new SnowTransfer("TOKEN")
|
|
117
|
+
* client.guildScheduledEvent.deleteGuildScheduledEvent(guildId, eventId)
|
|
118
|
+
*/
|
|
119
|
+
deleteGuildScheduledEvent(guildId: string, eventId: string): Promise<RESTDeleteAPIGuildScheduledEventResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Get a list of users attending a specific event
|
|
122
|
+
* @since 0.3.6
|
|
123
|
+
* @param guildId The Id of the guild
|
|
124
|
+
* @param eventId The Id of the event
|
|
125
|
+
* @param options Options for how to get users
|
|
126
|
+
* @returns An array of [event users](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure)
|
|
127
|
+
*
|
|
128
|
+
* | Permissions needed | Condition |
|
|
129
|
+
* |--------------------|-------------------------------------------|
|
|
130
|
+
* | VIEW_CHANNEL | if entity_type is STAGE_INSTANCE or VOICE |
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* const client = new SnowTransfer("TOKEN")
|
|
134
|
+
* const users = await client.guildScheduledEvent.getGuildScheduledEventUsers(guildId, eventId)
|
|
135
|
+
*/
|
|
136
|
+
getGuildScheduledEventUsers(guildId: string, eventId: string, options?: RESTGetAPIGuildScheduledEventUsersQuery): Promise<RESTGetAPIGuildScheduledEventUsersResult>;
|
|
137
|
+
}
|
|
138
|
+
export = GuildScheduledEventMethods;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Endpoints = require("../Endpoints");
|
|
3
|
+
const Constants = require("../Constants");
|
|
4
|
+
/**
|
|
5
|
+
* Methods for interacting with Guild Scheduled Events
|
|
6
|
+
* @since 0.3.6
|
|
7
|
+
*/
|
|
8
|
+
class GuildScheduledEventMethods {
|
|
9
|
+
requestHandler;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new Guild Scheduled Event 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.guildScheduledEvent.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 scheduled events for a guild
|
|
23
|
+
* @since 0.3.6
|
|
24
|
+
* @param guildId The Id of the guild
|
|
25
|
+
* @param withCounts Include number of users subscribed to each event
|
|
26
|
+
* @returns An array of [guild scheduled events](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const client = new SnowTransfer("TOKEN")
|
|
30
|
+
* const events = await client.guildScheduledEvent.listGuildScheduledEvents(guildId)
|
|
31
|
+
*/
|
|
32
|
+
async listGuildScheduledEvents(guildId, withCounts) {
|
|
33
|
+
return this.requestHandler.request(Endpoints.GUILD_SCHEDULED_EVENTS(guildId), { with_user_count: withCounts }, "get", "json");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a scheduled event for a guild
|
|
37
|
+
* @since 0.3.6
|
|
38
|
+
* @param guildId The Id of the guild
|
|
39
|
+
* @param data Data for the new scheduled event
|
|
40
|
+
* @param reason Reason for creating the scheduled event
|
|
41
|
+
* @returns A [scheduled event](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
42
|
+
*
|
|
43
|
+
* | Permissions needed | Condition |
|
|
44
|
+
* |--------------------|----------------------------------|
|
|
45
|
+
* | MANAGE_EVENTS | always |
|
|
46
|
+
* | MANAGE_CHANNELS | If entity_type is STAGE_INSTANCE |
|
|
47
|
+
* | MUTE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
48
|
+
* | MOVE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
49
|
+
* | VIEW_CHANNEL | If entity_type is VOICE |
|
|
50
|
+
* | CONNECT | If entity_type is VOICE |
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const client = new SnowTransfer("TOKEN")
|
|
54
|
+
* const eventData = {
|
|
55
|
+
* name: "My event!",
|
|
56
|
+
* entity_type: 1,
|
|
57
|
+
* start_time: "2020-01-01T00:00:00Z",
|
|
58
|
+
* privacy_level: 1
|
|
59
|
+
* }
|
|
60
|
+
* const event = await client.guildScheduledEvent.createGuildScheduledEvent(guildId, eventData)
|
|
61
|
+
*/
|
|
62
|
+
async createGuildScheduledEvent(guildId, data, reason) {
|
|
63
|
+
return this.requestHandler.request(Endpoints.GUILD_SCHEDULED_EVENTS(guildId), {}, "post", "json", data, Constants.reasonHeader(reason));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get a specific scheduled event for a guild
|
|
67
|
+
* @since 0.3.6
|
|
68
|
+
* @param guildId The Id of the guild
|
|
69
|
+
* @param eventId The Id of the event
|
|
70
|
+
* @param withCounts Include number of users subscribed to this event
|
|
71
|
+
* @returns A [scheduled event](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
72
|
+
*
|
|
73
|
+
* | Permissions needed | Condition |
|
|
74
|
+
* |--------------------|-------------------------------------------|
|
|
75
|
+
* | VIEW_CHANNEL | if entity_type is STAGE_INSTANCE or VOICE |
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const client = new SnowTransfer("TOKEN")
|
|
79
|
+
* const event = await client.guildScheduledEvent.getGuildScheduledEvent(guildId, eventId)
|
|
80
|
+
*/
|
|
81
|
+
async getGuildScheduledEvent(guildId, eventId, withCounts) {
|
|
82
|
+
return this.requestHandler.request(Endpoints.GUILD_SCHEDULED_EVENT(guildId, eventId), { with_user_count: withCounts }, "get", "json");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Edit the details of a scheduled event for a guild
|
|
86
|
+
* @since 0.3.6
|
|
87
|
+
* @param guildId The Id of the guild
|
|
88
|
+
* @param eventId The Id of the event
|
|
89
|
+
* @param data Edited scheduled event data
|
|
90
|
+
* @param reason Reason for editing the scheduled event
|
|
91
|
+
* @returns A [scheduled event](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-structure)
|
|
92
|
+
*
|
|
93
|
+
* | Permissions needed | Condition |
|
|
94
|
+
* |--------------------|----------------------------------|
|
|
95
|
+
* | MANAGE_EVENTS | always |
|
|
96
|
+
* | MANAGE_CHANNELS | If entity_type is STAGE_INSTANCE |
|
|
97
|
+
* | MUTE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
98
|
+
* | MOVE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
99
|
+
* | VIEW_CHANNEL | If entity_type is VOICE |
|
|
100
|
+
* | CONNECT | If entity_type is VOICE |
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Updates a scheduled event to be an external event that will take place in Brazil and end in 2025
|
|
104
|
+
* const client = new SnowTransfer("TOKEN")
|
|
105
|
+
* const event = await client.guildScheduledEvent.editGuildScheduledEvent(guildId, eventId, { entity_type: 3, channel_id: null, entity_metadata: { location: "Brazil" }, scheduled_end_time: "2025-01-01T00:00:00.000Z" })
|
|
106
|
+
*/
|
|
107
|
+
async editGuildScheduledEvent(guildId, eventId, data, reason) {
|
|
108
|
+
return this.requestHandler.request(Endpoints.GUILD_SCHEDULED_EVENT(guildId, eventId), {}, "patch", "json", data, Constants.reasonHeader(reason));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Delete a specific scheduled event for a guild
|
|
112
|
+
* @since 0.3.6
|
|
113
|
+
* @param guildId The Id of the guild
|
|
114
|
+
* @param eventId The Id of the event
|
|
115
|
+
* @returns Resolves the promise on successful execution
|
|
116
|
+
*
|
|
117
|
+
* | Permissions needed | Condition |
|
|
118
|
+
* |--------------------|----------------------------------|
|
|
119
|
+
* | MANAGE_EVENTS | always |
|
|
120
|
+
* | MANAGE_CHANNELS | If entity_type is STAGE_INSTANCE |
|
|
121
|
+
* | MUTE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
122
|
+
* | MOVE_MEMBERS | If entity_type is STAGE_INSTANCE |
|
|
123
|
+
* | VIEW_CHANNEL | If entity_type is VOICE |
|
|
124
|
+
* | CONNECT | If entity_type is VOICE |
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* const client = new SnowTransfer("TOKEN")
|
|
128
|
+
* client.guildScheduledEvent.deleteGuildScheduledEvent(guildId, eventId)
|
|
129
|
+
*/
|
|
130
|
+
async deleteGuildScheduledEvent(guildId, eventId) {
|
|
131
|
+
return this.requestHandler.request(Endpoints.GUILD_SCHEDULED_EVENT(guildId, eventId), {}, "delete", "json");
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get a list of users attending a specific event
|
|
135
|
+
* @since 0.3.6
|
|
136
|
+
* @param guildId The Id of the guild
|
|
137
|
+
* @param eventId The Id of the event
|
|
138
|
+
* @param options Options for how to get users
|
|
139
|
+
* @returns An array of [event users](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure)
|
|
140
|
+
*
|
|
141
|
+
* | Permissions needed | Condition |
|
|
142
|
+
* |--------------------|-------------------------------------------|
|
|
143
|
+
* | VIEW_CHANNEL | if entity_type is STAGE_INSTANCE or VOICE |
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const client = new SnowTransfer("TOKEN")
|
|
147
|
+
* const users = await client.guildScheduledEvent.getGuildScheduledEventUsers(guildId, eventId)
|
|
148
|
+
*/
|
|
149
|
+
async getGuildScheduledEventUsers(guildId, eventId, options) {
|
|
150
|
+
if (options?.limit !== undefined && (options.limit < Constants.GET_GUILD_SCHEDULED_EVENT_USERS_MIN_RESULTS || options.limit > Constants.GET_GUILD_SCHEDULED_EVENT_USERS_MAX_RESULTS))
|
|
151
|
+
throw new RangeError(`The maximum amount of users that may be requested has to be between ${Constants.GET_GUILD_SCHEDULED_EVENT_USERS_MIN_RESULTS} and ${Constants.GET_GUILD_SCHEDULED_EVENT_USERS_MAX_RESULTS}`);
|
|
152
|
+
return this.requestHandler.request(Endpoints.GUILD_SCHEDULED_EVENT_USERS(guildId, eventId), options, "get", "json");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
module.exports = GuildScheduledEventMethods;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { RequestHandler } from "../RequestHandler";
|
|
2
|
+
import type { RESTDeleteAPIGuildTemplateResult, RESTGetAPIGuildTemplatesResult, RESTGetAPITemplateResult, RESTPatchAPIGuildTemplateJSONBody, RESTPatchAPIGuildTemplateResult, RESTPostAPIGuildTemplatesJSONBody, RESTPostAPIGuildTemplatesResult, RESTPutAPIGuildTemplateSyncResult } from "discord-api-types/v10";
|
|
3
|
+
/**
|
|
4
|
+
* Methods for interacting with Guild Templates
|
|
5
|
+
* @since 0.3.0
|
|
6
|
+
*/
|
|
7
|
+
declare class GuildTemplateMethods {
|
|
8
|
+
readonly requestHandler: RequestHandler;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new Guild Template 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.guildTemplate.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 a guild template by code
|
|
20
|
+
* @since 0.3.0
|
|
21
|
+
* @param code The code for the template
|
|
22
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const client = new SnowTransfer("TOKEN")
|
|
26
|
+
* const template = await client.guildTemplate.getGuildTemplate("code")
|
|
27
|
+
*/
|
|
28
|
+
getGuildTemplate(code: string): Promise<RESTGetAPITemplateResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets all templates from a guild
|
|
31
|
+
* @since 0.3.0
|
|
32
|
+
* @param guildId The Id of the guild
|
|
33
|
+
* @returns An array of [guild templates](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
34
|
+
*
|
|
35
|
+
* | Permissions needed | Condition |
|
|
36
|
+
* |--------------------|-----------|
|
|
37
|
+
* | MANAGE_GUILD | always |
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const client = new SnowTransfer("TOKEN")
|
|
41
|
+
* const templates = await client.guildTemplate.getGuildTemplates("guildId")
|
|
42
|
+
*/
|
|
43
|
+
getGuildTemplates(guildId: string): Promise<RESTGetAPIGuildTemplatesResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a template from the current state of the guild
|
|
46
|
+
* @since 0.3.0
|
|
47
|
+
* @param guildId The Id of the guild
|
|
48
|
+
* @param data Metadata for the template
|
|
49
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
50
|
+
*
|
|
51
|
+
* | Permissions needed | Condition |
|
|
52
|
+
* |--------------------|-----------|
|
|
53
|
+
* | MANAGE_GUILD | always |
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const client = new SnowTransfer("TOKEN")
|
|
57
|
+
* const template = await client.guildTemplate.createGuildTemplate("guildId", { name: "Cool guild template", description: "This is a cool guild template" })
|
|
58
|
+
*/
|
|
59
|
+
createGuildTemplate(guildId: string, data: RESTPostAPIGuildTemplatesJSONBody): Promise<RESTPostAPIGuildTemplatesResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Updates a guild template to match the current state of the guild
|
|
62
|
+
* @since 0.3.0
|
|
63
|
+
* @param guildId The Id of the guild
|
|
64
|
+
* @param code The code of the template
|
|
65
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
66
|
+
*
|
|
67
|
+
* | Permissions needed | Condition |
|
|
68
|
+
* |--------------------|-----------|
|
|
69
|
+
* | MANAGE_GUILD | always |
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const client = new SnowTransfer("TOKEN")
|
|
73
|
+
* const template = await client.guildTemplate.syncGuildTemplate("guildId", "code")
|
|
74
|
+
*/
|
|
75
|
+
syncGuildTemplate(guildId: string, code: string): Promise<RESTPutAPIGuildTemplateSyncResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Updates a guild template's metadata
|
|
78
|
+
* @since 0.18.0
|
|
79
|
+
* @param guildId The Id of the guild
|
|
80
|
+
* @param code The code of the template
|
|
81
|
+
* @param data Metadata for the template
|
|
82
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
83
|
+
*
|
|
84
|
+
* | Permissions needed | Condition |
|
|
85
|
+
* |--------------------|-----------|
|
|
86
|
+
* | MANAGE_GUILD | always |
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* const client = new SnowTransfer("TOKEN")
|
|
90
|
+
* const template = await client.guildTemplate.editGuildTemplate("guildId", "code", { name: "Coolest guild template", description: "This is the coolest guild template hands down" })
|
|
91
|
+
*/
|
|
92
|
+
editGuildTemplate(guildId: string, code: string, data: RESTPatchAPIGuildTemplateJSONBody): Promise<RESTPatchAPIGuildTemplateResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Deletes a template from a guild
|
|
95
|
+
* @since 0.3.0
|
|
96
|
+
* @param guildId The Id of the guild
|
|
97
|
+
* @param code The code of the template
|
|
98
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
99
|
+
*
|
|
100
|
+
* | Permissions needed | Condition |
|
|
101
|
+
* |--------------------|-----------|
|
|
102
|
+
* | MANAGE_GUILD | always |
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const client = new SnowTransfer("TOKEN")
|
|
106
|
+
* const template = await client.guildTemplate.deleteGuildTemplate("guildId", "code")
|
|
107
|
+
*/
|
|
108
|
+
deleteGuildTemplate(guildId: string, code: string): Promise<RESTDeleteAPIGuildTemplateResult>;
|
|
109
|
+
}
|
|
110
|
+
export = GuildTemplateMethods;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Endpoints = require("../Endpoints");
|
|
3
|
+
/**
|
|
4
|
+
* Methods for interacting with Guild Templates
|
|
5
|
+
* @since 0.3.0
|
|
6
|
+
*/
|
|
7
|
+
class GuildTemplateMethods {
|
|
8
|
+
requestHandler;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new Guild Template 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.guildTemplate.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 a guild template by code
|
|
22
|
+
* @since 0.3.0
|
|
23
|
+
* @param code The code for the template
|
|
24
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const client = new SnowTransfer("TOKEN")
|
|
28
|
+
* const template = await client.guildTemplate.getGuildTemplate("code")
|
|
29
|
+
*/
|
|
30
|
+
async getGuildTemplate(code) {
|
|
31
|
+
return this.requestHandler.request(Endpoints.TEMPLATE(code), {}, "get", "json");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets all templates from a guild
|
|
35
|
+
* @since 0.3.0
|
|
36
|
+
* @param guildId The Id of the guild
|
|
37
|
+
* @returns An array of [guild templates](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
38
|
+
*
|
|
39
|
+
* | Permissions needed | Condition |
|
|
40
|
+
* |--------------------|-----------|
|
|
41
|
+
* | MANAGE_GUILD | always |
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const client = new SnowTransfer("TOKEN")
|
|
45
|
+
* const templates = await client.guildTemplate.getGuildTemplates("guildId")
|
|
46
|
+
*/
|
|
47
|
+
async getGuildTemplates(guildId) {
|
|
48
|
+
return this.requestHandler.request(Endpoints.GUILD_TEMPLATES(guildId), {}, "get", "json");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a template from the current state of the guild
|
|
52
|
+
* @since 0.3.0
|
|
53
|
+
* @param guildId The Id of the guild
|
|
54
|
+
* @param data Metadata for the template
|
|
55
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
56
|
+
*
|
|
57
|
+
* | Permissions needed | Condition |
|
|
58
|
+
* |--------------------|-----------|
|
|
59
|
+
* | MANAGE_GUILD | always |
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const client = new SnowTransfer("TOKEN")
|
|
63
|
+
* const template = await client.guildTemplate.createGuildTemplate("guildId", { name: "Cool guild template", description: "This is a cool guild template" })
|
|
64
|
+
*/
|
|
65
|
+
async createGuildTemplate(guildId, data) {
|
|
66
|
+
return this.requestHandler.request(Endpoints.GUILD_TEMPLATES(guildId), {}, "post", "json", data);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Updates a guild template to match the current state of the guild
|
|
70
|
+
* @since 0.3.0
|
|
71
|
+
* @param guildId The Id of the guild
|
|
72
|
+
* @param code The code of the template
|
|
73
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
74
|
+
*
|
|
75
|
+
* | Permissions needed | Condition |
|
|
76
|
+
* |--------------------|-----------|
|
|
77
|
+
* | MANAGE_GUILD | always |
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const client = new SnowTransfer("TOKEN")
|
|
81
|
+
* const template = await client.guildTemplate.syncGuildTemplate("guildId", "code")
|
|
82
|
+
*/
|
|
83
|
+
async syncGuildTemplate(guildId, code) {
|
|
84
|
+
return this.requestHandler.request(Endpoints.GUILD_TEMPLATE(guildId, code), {}, "put", "json");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Updates a guild template's metadata
|
|
88
|
+
* @since 0.18.0
|
|
89
|
+
* @param guildId The Id of the guild
|
|
90
|
+
* @param code The code of the template
|
|
91
|
+
* @param data Metadata for the template
|
|
92
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
93
|
+
*
|
|
94
|
+
* | Permissions needed | Condition |
|
|
95
|
+
* |--------------------|-----------|
|
|
96
|
+
* | MANAGE_GUILD | always |
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const client = new SnowTransfer("TOKEN")
|
|
100
|
+
* const template = await client.guildTemplate.editGuildTemplate("guildId", "code", { name: "Coolest guild template", description: "This is the coolest guild template hands down" })
|
|
101
|
+
*/
|
|
102
|
+
async editGuildTemplate(guildId, code, data) {
|
|
103
|
+
return this.requestHandler.request(Endpoints.GUILD_TEMPLATE(guildId, code), {}, "patch", "json", data);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Deletes a template from a guild
|
|
107
|
+
* @since 0.3.0
|
|
108
|
+
* @param guildId The Id of the guild
|
|
109
|
+
* @param code The code of the template
|
|
110
|
+
* @returns A [guild template](https://discord.com/developers/docs/resources/guild-template#guild-template-object-guild-template-structure)
|
|
111
|
+
*
|
|
112
|
+
* | Permissions needed | Condition |
|
|
113
|
+
* |--------------------|-----------|
|
|
114
|
+
* | MANAGE_GUILD | always |
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const client = new SnowTransfer("TOKEN")
|
|
118
|
+
* const template = await client.guildTemplate.deleteGuildTemplate("guildId", "code")
|
|
119
|
+
*/
|
|
120
|
+
async deleteGuildTemplate(guildId, code) {
|
|
121
|
+
return this.requestHandler.request(Endpoints.GUILD_TEMPLATE(guildId, code), {}, "delete", "json");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
module.exports = GuildTemplateMethods;
|