mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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');
|
||||
|
||||
/**
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -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>;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user