Skip to content

Commit 8f5ac55

Browse files
authored
fix!: Remove API related to guild ownership (#11021)
BREAKING CHANGE: API related to guild ownership has been removed, such as setting the MFA level, deleting a guild, creating a guild, and creating a guild from a guild template.
1 parent c3dc581 commit 8f5ac55

File tree

3 files changed

+0
-84
lines changed

3 files changed

+0
-84
lines changed

packages/discord.js/src/structures/Guild.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,29 +1434,6 @@ class Guild extends AnonymousGuild {
14341434
return this;
14351435
}
14361436

1437-
/**
1438-
* Sets the guild's MFA level
1439-
* <info>An elevated MFA level requires guild moderators to have 2FA enabled.</info>
1440-
*
1441-
* @param {GuildMFALevel} level The MFA level
1442-
* @param {string} [reason] Reason for changing the guild's MFA level
1443-
* @returns {Promise<Guild>}
1444-
* @example
1445-
* // Set the MFA level of the guild to Elevated
1446-
* guild.setMFALevel(GuildMFALevel.Elevated)
1447-
* .then(guild => console.log("Set guild's MFA level to Elevated"))
1448-
* .catch(console.error);
1449-
*/
1450-
async setMFALevel(level, reason) {
1451-
await this.client.rest.post(Routes.guildMFA(this.id), {
1452-
body: {
1453-
level,
1454-
},
1455-
reason,
1456-
});
1457-
return this;
1458-
}
1459-
14601437
/**
14611438
* Leaves the guild.
14621439
*
@@ -1473,21 +1450,6 @@ class Guild extends AnonymousGuild {
14731450
return this;
14741451
}
14751452

1476-
/**
1477-
* Deletes the guild.
1478-
*
1479-
* @returns {Promise<Guild>}
1480-
* @example
1481-
* // Delete a guild
1482-
* guild.delete()
1483-
* .then(guild => console.log(`Deleted the guild ${guild}`))
1484-
* .catch(console.error);
1485-
*/
1486-
async delete() {
1487-
await this.client.rest.delete(Routes.guild(this.id));
1488-
return this;
1489-
}
1490-
14911453
/**
14921454
* Sets whether this guild's invites are disabled.
14931455
*

packages/discord.js/src/structures/GuildTemplate.js

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
'use strict';
22

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

96
/**
@@ -127,46 +124,6 @@ class GuildTemplate extends Base {
127124
return this;
128125
}
129126

130-
/**
131-
* Creates a guild based on this template.
132-
* <warn>This is only available to bots in fewer than 10 guilds.</warn>
133-
*
134-
* @param {string} name The name of the guild
135-
* @param {BufferResolvable|Base64Resolvable} [icon] The icon for the guild
136-
* @returns {Promise<Guild>}
137-
*/
138-
async createGuild(name, icon) {
139-
const { client } = this;
140-
const data = await client.rest.post(Routes.template(this.code), {
141-
body: {
142-
name,
143-
icon: await resolveImage(icon),
144-
},
145-
});
146-
147-
if (client.guilds.cache.has(data.id)) return client.guilds.cache.get(data.id);
148-
149-
return new Promise(resolve => {
150-
function resolveGuild(guild) {
151-
client.off(Events.GuildCreate, handleGuild);
152-
client.decrementMaxListeners();
153-
resolve(guild);
154-
}
155-
156-
client.incrementMaxListeners();
157-
client.on(Events.GuildCreate, handleGuild);
158-
159-
const timeout = setTimeout(() => resolveGuild(client.guilds._add(data)), 10_000).unref();
160-
161-
function handleGuild(guild) {
162-
if (guild.id === data.id) {
163-
clearTimeout(timeout);
164-
resolveGuild(guild);
165-
}
166-
}
167-
});
168-
}
169-
170127
/**
171128
* Options used to edit a guild template.
172129
*

packages/discord.js/typings/index.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,6 @@ export class Guild extends AnonymousGuild {
14381438
public widgetEnabled: boolean | null;
14391439
public get maximumBitrate(): number;
14401440
public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
1441-
public delete(): Promise<Guild>;
14421441
public discoverySplashURL(options?: ImageURLOptions): string | null;
14431442
public edit(options: GuildEditOptions): Promise<Guild>;
14441443
public editOnboarding(options: GuildOnboardingEditOptions): Promise<GuildOnboarding>;
@@ -1489,7 +1488,6 @@ export class Guild extends AnonymousGuild {
14891488
public setVerificationLevel(verificationLevel: GuildVerificationLevel | null, reason?: string): Promise<Guild>;
14901489
public setPremiumProgressBarEnabled(enabled?: boolean, reason?: string): Promise<Guild>;
14911490
public setWidgetSettings(settings: GuildWidgetSettingsData, reason?: string): Promise<Guild>;
1492-
public setMFALevel(level: GuildMFALevel, reason?: string): Promise<Guild>;
14931491
public toJSON(): unknown;
14941492
}
14951493

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

0 commit comments

Comments
 (0)