mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat: add support for guild templates (#4907)
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
@@ -12,6 +12,7 @@ const UserManager = require('../managers/UserManager');
|
||||
const ShardClientUtil = require('../sharding/ShardClientUtil');
|
||||
const ClientApplication = require('../structures/ClientApplication');
|
||||
const GuildPreview = require('../structures/GuildPreview');
|
||||
const GuildTemplate = require('../structures/GuildTemplate');
|
||||
const Invite = require('../structures/Invite');
|
||||
const VoiceRegion = require('../structures/VoiceRegion');
|
||||
const Webhook = require('../structures/Webhook');
|
||||
@@ -254,6 +255,23 @@ class Client extends BaseClient {
|
||||
.then(data => new Invite(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a template from Discord.
|
||||
* @param {GuildTemplateResolvable} template Template code or URL
|
||||
* @returns {Promise<GuildTemplate>}
|
||||
* @example
|
||||
* client.fetchGuildTemplate('https://discord.new/FKvmczH2HyUf')
|
||||
* .then(template => console.log(`Obtained template with code: ${template.code}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
fetchGuildTemplate(template) {
|
||||
const code = DataResolver.resolveGuildTemplateCode(template);
|
||||
return this.api.guilds
|
||||
.templates(code)
|
||||
.get()
|
||||
.then(data => new GuildTemplate(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a webhook from Discord.
|
||||
* @param {Snowflake} id ID of the webhook
|
||||
|
||||
Reference in New Issue
Block a user