mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
feat: GuildEmbed support (#2766)
* feat: Guild embed support * docs: Fixed setEmbed's reason argument not being optional * fix: Guild#setEmbed should return the guild itself for consistency * docs: Updated typings * fix: Requested change
This commit is contained in:
@@ -483,6 +483,29 @@ class Guild extends Base {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Guild Embed object
|
||||||
|
* @typedef {Object} GuildEmbedData
|
||||||
|
* @property {boolean} enabled Whether the embed is enabled
|
||||||
|
* @property {?GuildChannel} channel The embed channel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the guild embed.
|
||||||
|
* @returns {Promise<GuildEmbedData>}
|
||||||
|
* @example
|
||||||
|
* // Fetches the guild embed
|
||||||
|
* guild.fetchEmbed()
|
||||||
|
* .then(embed => console.log(`The embed is ${embed.enabled ? 'enabled' : 'disabled'}`))
|
||||||
|
* .catch(console.error);
|
||||||
|
*/
|
||||||
|
fetchEmbed() {
|
||||||
|
return this.client.api.guilds(this.id).embed.get().then(data => ({
|
||||||
|
enabled: data.enabled,
|
||||||
|
channel: data.channel_id ? this.channels.get(data.channel_id) : null,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches audit logs for this guild.
|
* Fetches audit logs for this guild.
|
||||||
* @param {Object} [options={}] Options for fetching audit logs
|
* @param {Object} [options={}] Options for fetching audit logs
|
||||||
@@ -790,6 +813,22 @@ class Guild extends Base {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits the guild's embed.
|
||||||
|
* @param {GuildEmbedData} embed The embed for the guild
|
||||||
|
* @param {string} [reason] Reason for changing the guild's embed
|
||||||
|
* @returns {Promise<Guild>}
|
||||||
|
*/
|
||||||
|
setEmbed(embed, reason) {
|
||||||
|
return this.client.api.guilds(this.id).embed.patch({
|
||||||
|
data: {
|
||||||
|
enabled: embed.enabled,
|
||||||
|
channel_id: this.channels.resolveID(embed.channel),
|
||||||
|
},
|
||||||
|
reason,
|
||||||
|
}).then(() => this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leaves the guild.
|
* Leaves the guild.
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
|
|||||||
7
typings/index.d.ts
vendored
7
typings/index.d.ts
vendored
@@ -395,6 +395,7 @@ declare module 'discord.js' {
|
|||||||
public fetchVanityCode(): Promise<string>;
|
public fetchVanityCode(): Promise<string>;
|
||||||
public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
|
public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>;
|
||||||
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
public fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
|
||||||
|
public fetchEmbed(): Promise<GuildEmbedData>;
|
||||||
public iconURL(options?: AvatarOptions): string;
|
public iconURL(options?: AvatarOptions): string;
|
||||||
public leave(): Promise<Guild>;
|
public leave(): Promise<Guild>;
|
||||||
public member(user: UserResolvable): GuildMember;
|
public member(user: UserResolvable): GuildMember;
|
||||||
@@ -410,6 +411,7 @@ declare module 'discord.js' {
|
|||||||
public setSplash(splash: Base64Resolvable, reason?: string): Promise<Guild>;
|
public setSplash(splash: Base64Resolvable, reason?: string): Promise<Guild>;
|
||||||
public setSystemChannel(systemChannel: ChannelResolvable, reason?: string): Promise<Guild>;
|
public setSystemChannel(systemChannel: ChannelResolvable, reason?: string): Promise<Guild>;
|
||||||
public setVerificationLevel(verificationLevel: number, reason?: string): Promise<Guild>;
|
public setVerificationLevel(verificationLevel: number, reason?: string): Promise<Guild>;
|
||||||
|
public setEmbed(embed: GuildEmbedData, reason?: string): Promise<Guild>;
|
||||||
public splashURL(options?: AvatarOptions): string;
|
public splashURL(options?: AvatarOptions): string;
|
||||||
public toJSON(): object;
|
public toJSON(): object;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
@@ -1698,6 +1700,11 @@ declare module 'discord.js' {
|
|||||||
splash?: Base64Resolvable;
|
splash?: Base64Resolvable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type GuildEmbedData = {
|
||||||
|
enabled: boolean;
|
||||||
|
channel?: GuildChannelResolvable;
|
||||||
|
};
|
||||||
|
|
||||||
type GuildFeatures = 'INVITE_SPLASH'
|
type GuildFeatures = 'INVITE_SPLASH'
|
||||||
| 'MORE_EMOJI'
|
| 'MORE_EMOJI'
|
||||||
| 'VERIFIED'
|
| 'VERIFIED'
|
||||||
|
|||||||
Reference in New Issue
Block a user