Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions packages/discord.js/src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,29 +1434,6 @@ class Guild extends AnonymousGuild {
return this;
}

/**
* Sets the guild's MFA level
* <info>An elevated MFA level requires guild moderators to have 2FA enabled.</info>
*
* @param {GuildMFALevel} level The MFA level
* @param {string} [reason] Reason for changing the guild's MFA level
* @returns {Promise<Guild>}
* @example
* // Set the MFA level of the guild to Elevated
* guild.setMFALevel(GuildMFALevel.Elevated)
* .then(guild => console.log("Set guild's MFA level to Elevated"))
* .catch(console.error);
*/
async setMFALevel(level, reason) {
await this.client.rest.post(Routes.guildMFA(this.id), {
body: {
level,
},
reason,
});
return this;
}

/**
* Leaves the guild.
*
Expand All @@ -1473,21 +1450,6 @@ class Guild extends AnonymousGuild {
return this;
}

/**
* Deletes the guild.
*
* @returns {Promise<Guild>}
* @example
* // Delete a guild
* guild.delete()
* .then(guild => console.log(`Deleted the guild ${guild}`))
* .catch(console.error);
*/
async delete() {
await this.client.rest.delete(Routes.guild(this.id));
return this;
}

/**
* Sets whether this guild's invites are disabled.
*
Expand Down
43 changes: 0 additions & 43 deletions packages/discord.js/src/structures/GuildTemplate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

const { setTimeout, clearTimeout } = require('node:timers');
const { RouteBases, Routes } = require('discord-api-types/v10');
const { resolveImage } = require('../util/DataResolver.js');
const { Events } = require('../util/Events.js');
const { Base } = require('./Base.js');

/**
Expand Down Expand Up @@ -127,46 +124,6 @@ class GuildTemplate extends Base {
return this;
}

/**
* Creates a guild based on this template.
* <warn>This is only available to bots in fewer than 10 guilds.</warn>
*
* @param {string} name The name of the guild
* @param {BufferResolvable|Base64Resolvable} [icon] The icon for the guild
* @returns {Promise<Guild>}
*/
async createGuild(name, icon) {
const { client } = this;
const data = await client.rest.post(Routes.template(this.code), {
body: {
name,
icon: await resolveImage(icon),
},
});

if (client.guilds.cache.has(data.id)) return client.guilds.cache.get(data.id);

return new Promise(resolve => {
function resolveGuild(guild) {
client.off(Events.GuildCreate, handleGuild);
client.decrementMaxListeners();
resolve(guild);
}

client.incrementMaxListeners();
client.on(Events.GuildCreate, handleGuild);

const timeout = setTimeout(() => resolveGuild(client.guilds._add(data)), 10_000).unref();

function handleGuild(guild) {
if (guild.id === data.id) {
clearTimeout(timeout);
resolveGuild(guild);
}
}
});
}

/**
* Options used to edit a guild template.
*
Expand Down
3 changes: 0 additions & 3 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,6 @@ export class Guild extends AnonymousGuild {
public widgetEnabled: boolean | null;
public get maximumBitrate(): number;
public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
public delete(): Promise<Guild>;
public discoverySplashURL(options?: ImageURLOptions): string | null;
public edit(options: GuildEditOptions): Promise<Guild>;
public editOnboarding(options: GuildOnboardingEditOptions): Promise<GuildOnboarding>;
Expand Down Expand Up @@ -1489,7 +1488,6 @@ export class Guild extends AnonymousGuild {
public setVerificationLevel(verificationLevel: GuildVerificationLevel | null, reason?: string): Promise<Guild>;
public setPremiumProgressBarEnabled(enabled?: boolean, reason?: string): Promise<Guild>;
public setWidgetSettings(settings: GuildWidgetSettingsData, reason?: string): Promise<Guild>;
public setMFALevel(level: GuildMFALevel, reason?: string): Promise<Guild>;
public toJSON(): unknown;
}

Expand Down Expand Up @@ -1824,7 +1822,6 @@ export class GuildTemplate extends Base {
public guildId: Snowflake;
public serializedGuild: APITemplateSerializedSourceGuild;
public unSynced: boolean | null;
public createGuild(name: string, icon?: Base64Resolvable | BufferResolvable): Promise<Guild>;
public delete(): Promise<GuildTemplate>;
public edit(options?: GuildTemplateEditOptions): Promise<GuildTemplate>;
public sync(): Promise<GuildTemplate>;
Expand Down