mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
Server Templates 🎉🎉
This commit is contained in:
@@ -622,3 +622,31 @@ export function getGuild(guildID: string, counts = true) {
|
|||||||
{ with_counts: counts },
|
{ with_counts: counts },
|
||||||
) as Promise<UpdateGuildPayload>;
|
) as Promise<UpdateGuildPayload>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a template by its code
|
||||||
|
* @param code The code of the template
|
||||||
|
*/
|
||||||
|
export function getTemplate(code: string) {
|
||||||
|
const endpoint = `${endpoints.GUILDS}/templates/${code}`;
|
||||||
|
return RequestManager.get(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new guild based on a template.
|
||||||
|
* NOTE: This endpoint can be used only by bots in less than 10 guilds.
|
||||||
|
* @param code the code of the template to create a new guild from
|
||||||
|
* @param name name of the guild (2-100 characters)
|
||||||
|
* @param icon base64 128x128 image for the guild icon
|
||||||
|
*/
|
||||||
|
export function createGuildFromTemplate(
|
||||||
|
code: string,
|
||||||
|
name: string,
|
||||||
|
icon?: any,
|
||||||
|
) {
|
||||||
|
const endpoint = `${endpoints.GUILDS}/templates/${code}`;
|
||||||
|
return RequestManager.post(endpoint, {
|
||||||
|
name,
|
||||||
|
icon,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { Guild } from "../structures/guild.ts";
|
||||||
import { ChannelCreatePayload, ChannelTypes } from "./channel.ts";
|
import { ChannelCreatePayload, ChannelTypes } from "./channel.ts";
|
||||||
import { Emoji, StatusType } from "./discord.ts";
|
import { Emoji, StatusType } from "./discord.ts";
|
||||||
import { MemberCreatePayload } from "./member.ts";
|
import { MemberCreatePayload } from "./member.ts";
|
||||||
@@ -606,3 +607,29 @@ export interface CreateServerOptions {
|
|||||||
/** the id of the channel where guild notices such as welcome messages and boost events are posted */
|
/** the id of the channel where guild notices such as welcome messages and boost events are posted */
|
||||||
system_channel_id?: string;
|
system_channel_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/template#template-object
|
||||||
|
export interface GuildTemplate {
|
||||||
|
/** the template code (unique ID) */
|
||||||
|
code: string;
|
||||||
|
/** template name */
|
||||||
|
name: string;
|
||||||
|
/** the description for the template */
|
||||||
|
description: string | null;
|
||||||
|
/** number of times this template has been used */
|
||||||
|
usage_count: number;
|
||||||
|
/** the ID of the user who created the template */
|
||||||
|
creator_id: string;
|
||||||
|
/** the user who created the template */
|
||||||
|
user: UserPayload;
|
||||||
|
/** when this template was created */
|
||||||
|
created_at: string;
|
||||||
|
/** when this template was last synced to the source guild */
|
||||||
|
updated_at: string;
|
||||||
|
/** the ID of the guild this template is based on */
|
||||||
|
source_guild_id: string;
|
||||||
|
/** the guild snapshot this template contains */
|
||||||
|
serialized_source_guild: Guild;
|
||||||
|
/** whether the template has unsynced changes */
|
||||||
|
is_dirty: boolean | null;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user