Skip to content

Commit 28ef5ab

Browse files
committed
refactor(GuildTemplate): name param can now be optional on 'edit'
- see: discord/discord-api-docs#2144 (comment)
1 parent d24829a commit 28ef5ab

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/structures/GuildTemplate.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,12 @@ class GuildTemplate extends Base {
136136

137137
/**
138138
* Updates the metadata on this template.
139-
* @param {string} [name=this.name] The name of this template
140-
* @param {?string} [description] The description of this template
139+
* @param {Object} options Options for the template
140+
* @param {string} [options.name] The name of this template
141+
* @param {string} [options.description] The description of this template
141142
* @returns {Promise<GuildTemplate>}
142143
*/
143-
// The name must be provided as of this commit's date, the default value can be removed after this has been changed
144-
// (https://github.com/discord/discord-api-docs/pull/2144#discussion_r502952362)
145-
edit(name = this.name, description) {
144+
edit({ name, description } = {}) {
146145
return this.api
147146
.guilds(this.guildID)
148147
.templates(this.code)

typings/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ declare module 'discord.js' {
213213
public fetchApplication(): Promise<ClientApplication>;
214214
public fetchGuildPreview(guild: GuildResolvable): Promise<GuildPreview>;
215215
public fetchInvite(invite: InviteResolvable): Promise<Invite>;
216-
public fetchGuildTemplate(): Promise<GuildTemplate>;
216+
public fetchGuildTemplate(template: GuildTemplateResolvable): Promise<GuildTemplate>;
217217
public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
218218
public fetchWebhook(id: Snowflake, token?: string): Promise<Webhook>;
219219
public generateInvite(options?: InviteGenerationOptions | PermissionResolvable): Promise<string>;
@@ -923,10 +923,10 @@ declare module 'discord.js' {
923923
public guildID: string;
924924
public guild: Guild;
925925
public unSynced: boolean | null;
926-
public createGuild(name: string, icon?: BufferResolvable | Base64Resolvable): Guild;
927-
public delete(): GuildTemplate;
928-
public edit(name: string, description?: string): GuildTemplate;
929-
public sync(): GuildTemplate;
926+
public createGuild(name: string, icon?: BufferResolvable | Base64Resolvable): Promise<Guild>;
927+
public delete(): Promise<GuildTemplate>;
928+
public edit(options?: { name?: string; description?: string }): Promise<GuildTemplate>;
929+
public sync(): Promise<GuildTemplate>;
930930
}
931931

932932
export class GuildPreviewEmoji extends BaseGuildEmoji {

0 commit comments

Comments
 (0)