mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-06-04 09:50:09 +00:00
feat: server templates (#25)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
@@ -52,6 +52,8 @@ export enum RESTJSONErrorCodes {
|
||||
MaximumNumberOfAttachmentsInAMessageReached = 30015,
|
||||
MaximumNumberOfInvitesReached,
|
||||
|
||||
GuildAlreadyHasTemplate = 30031,
|
||||
|
||||
Unauthorized = 40001,
|
||||
VerifyYourAccount,
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ export interface APIUnavailableGuild {
|
||||
unavailable: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
|
||||
*/
|
||||
export interface APIPartialGuild extends Omit<APIUnavailableGuild, 'unavailable'>, Pick<APIGuild, 'welcome_screen'> {
|
||||
name: string;
|
||||
icon: string | null;
|
||||
@@ -29,7 +32,11 @@ export interface APIPartialGuild extends Omit<APIUnavailableGuild, 'unavailable'
|
||||
unavailable?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
|
||||
*/
|
||||
export interface APIGuild extends APIPartialGuild {
|
||||
icon_hash?: string | null;
|
||||
discovery_splash: string | null;
|
||||
owner?: boolean;
|
||||
owner_id: string;
|
||||
|
||||
@@ -7,6 +7,7 @@ export * from './invite';
|
||||
export * from './oauth2';
|
||||
export * from './permissions';
|
||||
export * from './teams';
|
||||
export * from './template';
|
||||
export * from './user';
|
||||
export * from './voice';
|
||||
export * from './webhook';
|
||||
|
||||
29
v8/payloads/template.ts
Normal file
29
v8/payloads/template.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Types extracted from https://discord.com/developers/docs/resources/template
|
||||
*/
|
||||
|
||||
import type { APIUser } from './user';
|
||||
import type { RESTPostAPIGuildsJSONBody } from '../rest';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/template#template-object
|
||||
*/
|
||||
export interface APITemplate {
|
||||
code: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
usage_count: number;
|
||||
creator_id: string;
|
||||
creator: APIUser;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
source_guild_id: string;
|
||||
serialized_source_guild: APITemplateSerializedSourceGuild;
|
||||
is_dirty: boolean | null;
|
||||
}
|
||||
|
||||
export interface APITemplateSerializedSourceGuild extends Omit<RESTPostAPIGuildsJSONBody, 'icon'> {
|
||||
description: string | null;
|
||||
preferred_locale: string;
|
||||
icon_hash: string | null;
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
GuildDefaultMessageNotifications,
|
||||
GuildExplicitContentFilter,
|
||||
GuildFeature,
|
||||
GuildSystemChannelFlags,
|
||||
GuildVerificationLevel,
|
||||
GuildWidgetStyle,
|
||||
IntegrationExpireBehavior,
|
||||
@@ -51,6 +52,7 @@ export interface RESTPostAPIGuildsJSONBody {
|
||||
afk_channel_id?: number | string;
|
||||
afk_timeout?: number;
|
||||
system_channel_id?: number | string;
|
||||
system_channel_flags: GuildSystemChannelFlags;
|
||||
}
|
||||
|
||||
export type RESTPostAPIGuildsResult = APIGuild;
|
||||
@@ -86,6 +88,7 @@ export interface RESTPatchAPIGuildJSONBody {
|
||||
discovery_splash?: string | null;
|
||||
banner?: string | null;
|
||||
system_channel_id?: string | null;
|
||||
system_channel_flags: GuildSystemChannelFlags;
|
||||
rules_channel_id?: string | null;
|
||||
public_updates_channel_id?: string | null;
|
||||
preferred_locale?: string;
|
||||
|
||||
@@ -5,6 +5,7 @@ export * from './gateway';
|
||||
export * from './guild';
|
||||
export * from './invite';
|
||||
export * from './oauth2';
|
||||
export * from './template';
|
||||
export * from './user';
|
||||
export * from './voice';
|
||||
export * from './webhook';
|
||||
@@ -393,6 +394,34 @@ export const Routes = {
|
||||
return `/invites/${code}`;
|
||||
},
|
||||
|
||||
/**
|
||||
* Route for:
|
||||
* - GET `/guilds/templates/{template.code}`
|
||||
* - POST `/guilds/templates/{template.code}`
|
||||
*/
|
||||
template(code: string) {
|
||||
return `/guilds/templates/${code}`;
|
||||
},
|
||||
|
||||
/**
|
||||
* Route for:
|
||||
* - GET `/guilds/{guild.id}/templates`
|
||||
* - POST `/guilds/{guild.id}/templates`
|
||||
*/
|
||||
guildTemplates(guildID: string) {
|
||||
return `/guilds/${guildID}/templates`;
|
||||
},
|
||||
|
||||
/**
|
||||
* Route for:
|
||||
* - PUT `/guilds/{guild.id}/templates/{template.code}`
|
||||
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
|
||||
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
|
||||
*/
|
||||
guildTemplate(guildID: string, code: string) {
|
||||
return `/guilds/${guildID}/templates/${code}`;
|
||||
},
|
||||
|
||||
/**
|
||||
* Route for:
|
||||
* - GET `/users/@me`
|
||||
|
||||
33
v8/rest/template.ts
Normal file
33
v8/rest/template.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { APIGuild, APITemplate } from '../payloads';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/template#get-template
|
||||
*/
|
||||
export type RESTGetAPITemplateResult = APITemplate;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/template#create-guild-from-template
|
||||
*/
|
||||
export interface RESTPostAPITemplateCreateGuildJSONBody {
|
||||
name: string;
|
||||
icon?: string;
|
||||
}
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/template#create-guild-from-template
|
||||
*/
|
||||
export type RESTPostAPITemplateCreateGuildResult = APIGuild;
|
||||
|
||||
export type RESTGetAPIGuildTemplatesResult = APITemplate[];
|
||||
|
||||
export interface RESTPostAPIGuildTemplatesJSONBody {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
}
|
||||
export type RESTPostAPIGuildTemplatesResult = APITemplate;
|
||||
|
||||
export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
|
||||
|
||||
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
|
||||
export type RESTPatchAPIGuildTemplateResult = APITemplate;
|
||||
|
||||
export type RESTDeleteAPIGuildTemplateResult = APITemplate;
|
||||
Reference in New Issue
Block a user