fix!: Remove guild creation (#11012)

BREAKING CHANGE: Guild creation is no longer possible.
This commit is contained in:
Jiralite
2025-07-26 12:25:36 +01:00
committed by GitHub
parent 6cdfa3864b
commit 2e9bfba5f4
3 changed files with 0 additions and 208 deletions

View File

@@ -89,9 +89,7 @@ import {
type RESTPostAPIGuildStickerResult, type RESTPostAPIGuildStickerResult,
type RESTPostAPIGuildTemplatesJSONBody, type RESTPostAPIGuildTemplatesJSONBody,
type RESTPostAPIGuildTemplatesResult, type RESTPostAPIGuildTemplatesResult,
type RESTPostAPIGuildsJSONBody,
type RESTPostAPIGuildsMFAResult, type RESTPostAPIGuildsMFAResult,
type RESTPostAPIGuildsResult,
type RESTPutAPIGuildBanJSONBody, type RESTPutAPIGuildBanJSONBody,
type RESTPutAPIGuildMemberJSONBody, type RESTPutAPIGuildMemberJSONBody,
type RESTPutAPIGuildMemberResult, type RESTPutAPIGuildMemberResult,
@@ -148,17 +146,6 @@ export class GuildsAPI {
}) as Promise<RESTGetAPIGuildPreviewResult>; }) as Promise<RESTGetAPIGuildPreviewResult>;
} }
/**
* Creates a guild
*
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild}
* @param body - The guild to create
* @param options - The options for creating the guild
*/
public async create(body: RESTPostAPIGuildsJSONBody, { auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}) {
return this.rest.post(Routes.guilds(), { auth, body, signal }) as Promise<RESTPostAPIGuildsResult>;
}
/** /**
* Edits a guild * Edits a guild
* *

View File

@@ -14,12 +14,8 @@ const { GuildInvite } = require('../structures/GuildInvite.js');
const { GuildMember } = require('../structures/GuildMember.js'); const { GuildMember } = require('../structures/GuildMember.js');
const { OAuth2Guild } = require('../structures/OAuth2Guild.js'); const { OAuth2Guild } = require('../structures/OAuth2Guild.js');
const { Role } = require('../structures/Role.js'); const { Role } = require('../structures/Role.js');
const { resolveImage } = require('../util/DataResolver.js');
const { Events } = require('../util/Events.js'); const { Events } = require('../util/Events.js');
const { PermissionsBitField } = require('../util/PermissionsBitField.js');
const { SystemChannelFlagsBitField } = require('../util/SystemChannelFlagsBitField.js');
const { _transformAPIIncidentsData } = require('../util/Transformers.js'); const { _transformAPIIncidentsData } = require('../util/Transformers.js');
const { resolveColor } = require('../util/Util.js');
const { CachedManager } = require('./CachedManager.js'); const { CachedManager } = require('./CachedManager.js');
let cacheWarningEmitted = false; let cacheWarningEmitted = false;
@@ -60,50 +56,6 @@ class GuildManager extends CachedManager {
* @typedef {Guild|GuildChannel|GuildMember|GuildEmoji|Role|Snowflake|Invite} GuildResolvable * @typedef {Guild|GuildChannel|GuildMember|GuildEmoji|Role|Snowflake|Invite} GuildResolvable
*/ */
/**
* Partial data for a Role.
*
* @typedef {Object} PartialRoleData
* @property {Snowflake|number} [id] The role's id, used to set channel overrides.
* This is a placeholder and will be replaced by the API after consumption
* @property {string} [name] The name of the role
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
* @property {boolean} [hoist] Whether the role should be hoisted
* @property {number} [position] The position of the role
* @property {PermissionResolvable} [permissions] The permissions of the role
* @property {boolean} [mentionable] Whether the role should be mentionable
*/
/**
* Partial overwrite data.
*
* @typedef {Object} PartialOverwriteData
* @property {Snowflake|number} id The id of the {@link Role} or {@link User} this overwrite belongs to
* @property {OverwriteType} [type] The type of this overwrite
* @property {PermissionResolvable} [allow] The permissions to allow
* @property {PermissionResolvable} [deny] The permissions to deny
*/
/**
* Partial data for a Channel.
*
* @typedef {Object} PartialChannelData
* @property {Snowflake|number} [id] The channel's id, used to set its parent.
* This is a placeholder and will be replaced by the API after consumption
* @property {Snowflake|number} [parentId] The parent id for this channel
* @property {ChannelType.GuildText|ChannelType.GuildVoice|ChannelType.GuildCategory} [type] The type of the channel
* @property {string} name The name of the channel
* @property {?string} [topic] The topic of the text channel
* @property {boolean} [nsfw] Whether the channel is NSFW
* @property {number} [bitrate] The bitrate of the voice channel
* @property {number} [userLimit] The user limit of the channel
* @property {?string} [rtcRegion] The RTC region of the channel
* @property {VideoQualityMode} [videoQualityMode] The camera video quality mode of the channel
* @property {PartialOverwriteData[]} [permissionOverwrites]
* Overwrites of the channel
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) of the channel in seconds
*/
/** /**
* Resolves a {@link GuildResolvable} to a {@link Guild} object. * Resolves a {@link GuildResolvable} to a {@link Guild} object.
* *
@@ -150,112 +102,6 @@ class GuildManager extends CachedManager {
return super.resolveId(guild); return super.resolveId(guild);
} }
/**
* Options used to create a guild.
*
* @typedef {Object} GuildCreateOptions
* @property {string} name The name of the guild
* @property {?(BufferResolvable|Base64Resolvable)} [icon=null] The icon for the guild
* @property {GuildVerificationLevel} [verificationLevel] The verification level for the guild
* @property {GuildDefaultMessageNotifications} [defaultMessageNotifications] The default message notifications
* for the guild
* @property {GuildExplicitContentFilter} [explicitContentFilter] The explicit content filter level for the guild
* @property {PartialRoleData[]} [roles=[]] The roles for this guild,
* @property {PartialChannelData[]} [channels=[]] The channels for this guild
* @property {Snowflake|number} [afkChannelId] The AFK channel's id
* @property {number} [afkTimeout] The AFK timeout in seconds
* the first element of this array is used to change properties of the guild's everyone role.
* @property {Snowflake|number} [systemChannelId] The system channel's id
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The flags of the system channel
*/
/**
* Creates a guild.
* <warn>This is only available to bots in fewer than 10 guilds.</warn>
*
* @param {GuildCreateOptions} options Options for creating the guild
* @returns {Promise<Guild>} The guild that was created
*/
async create({
name,
icon = null,
verificationLevel,
defaultMessageNotifications,
explicitContentFilter,
roles = [],
channels = [],
afkChannelId,
afkTimeout,
systemChannelId,
systemChannelFlags,
}) {
const data = await this.client.rest.post(Routes.guilds(), {
body: {
name,
icon: icon && (await resolveImage(icon)),
verification_level: verificationLevel,
default_message_notifications: defaultMessageNotifications,
explicit_content_filter: explicitContentFilter,
roles: roles.map(({ color, permissions, ...options }) => ({
...options,
color: color && resolveColor(color),
permissions: permissions === undefined ? undefined : PermissionsBitField.resolve(permissions).toString(),
})),
channels: channels.map(
({
parentId,
userLimit,
rtcRegion,
videoQualityMode,
permissionOverwrites,
rateLimitPerUser,
...options
}) => ({
...options,
parent_id: parentId,
user_limit: userLimit,
rtc_region: rtcRegion,
video_quality_mode: videoQualityMode,
permission_overwrites: permissionOverwrites?.map(({ allow, deny, ...permissionOverwriteOptions }) => ({
...permissionOverwriteOptions,
allow: allow === undefined ? undefined : PermissionsBitField.resolve(allow).toString(),
deny: deny === undefined ? undefined : PermissionsBitField.resolve(deny).toString(),
})),
rate_limit_per_user: rateLimitPerUser,
}),
),
afk_channel_id: afkChannelId,
afk_timeout: afkTimeout,
system_channel_id: systemChannelId,
system_channel_flags:
systemChannelFlags === undefined ? undefined : SystemChannelFlagsBitField.resolve(systemChannelFlags),
},
});
return (
this.client.guilds.cache.get(data.id) ??
new Promise(resolve => {
const handleGuild = guild => {
if (guild.id === data.id) {
// eslint-disable-next-line no-use-before-define
clearTimeout(timeout);
this.client.decrementMaxListeners();
resolve(guild);
}
};
this.client.incrementMaxListeners();
this.client.once(Events.GuildCreate, handleGuild);
const timeout = setTimeout(() => {
this.client.removeListener(Events.GuildCreate, handleGuild);
this.client.decrementMaxListeners();
resolve(this.client.guilds._add(data));
}, 10_000).unref();
})
);
}
/** /**
* Options used to fetch a single guild. * Options used to fetch a single guild.
* *

View File

@@ -4347,7 +4347,6 @@ export interface FetchSoundboardSoundsOptions {
export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvable> { export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvable> {
private constructor(client: Client<true>, iterable?: Iterable<APIGuild | APIUnavailableGuild>); private constructor(client: Client<true>, iterable?: Iterable<APIGuild | APIUnavailableGuild>);
public create(options: GuildCreateOptions): Promise<Guild>;
public fetch(options: FetchGuildOptions | Snowflake): Promise<Guild>; public fetch(options: FetchGuildOptions | Snowflake): Promise<Guild>;
public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>; public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>;
public fetchSoundboardSounds( public fetchSoundboardSounds(
@@ -6111,20 +6110,6 @@ export interface GuildChannelOverwriteOptions {
type?: OverwriteType; type?: OverwriteType;
} }
export interface GuildCreateOptions {
afkChannelId?: Snowflake | number;
afkTimeout?: number;
channels?: readonly PartialChannelData[];
defaultMessageNotifications?: GuildDefaultMessageNotifications;
explicitContentFilter?: GuildExplicitContentFilter;
icon?: Base64Resolvable | BufferResolvable | null;
name: string;
roles?: readonly PartialRoleData[];
systemChannelFlags?: SystemChannelFlagsResolvable;
systemChannelId?: Snowflake | number;
verificationLevel?: GuildVerificationLevel;
}
export interface GuildWidgetSettings { export interface GuildWidgetSettings {
channel: AnnouncementChannel | ForumChannel | MediaChannel | TextChannel | VoiceBasedChannel | null; channel: AnnouncementChannel | ForumChannel | MediaChannel | TextChannel | VoiceBasedChannel | null;
enabled: boolean; enabled: boolean;
@@ -6788,21 +6773,6 @@ export interface PresenceData {
export type PresenceResolvable = Presence | Snowflake | UserResolvable; export type PresenceResolvable = Presence | Snowflake | UserResolvable;
export interface PartialChannelData {
bitrate?: number;
id?: Snowflake | number;
name: string;
nsfw?: boolean;
parentId?: Snowflake | number;
permissionOverwrites?: readonly PartialOverwriteData[];
rateLimitPerUser?: number;
rtcRegion?: string | null;
topic?: string | null;
type?: ChannelType.GuildCategory | ChannelType.GuildText | ChannelType.GuildVoice;
userLimit?: number;
videoQualityMode?: VideoQualityMode;
}
export interface PartialEmoji { export interface PartialEmoji {
animated: boolean; animated: boolean;
id: Snowflake | undefined; id: Snowflake | undefined;
@@ -6863,17 +6833,6 @@ export interface PartialThreadMember extends Partialize<ThreadMember, 'flags' |
export interface PartialSoundboardSound extends Partialize<SoundboardSound, 'available' | 'name' | 'volume'> {} export interface PartialSoundboardSound extends Partialize<SoundboardSound, 'available' | 'name' | 'volume'> {}
export interface PartialOverwriteData {
allow?: PermissionResolvable;
deny?: PermissionResolvable;
id: Snowflake | number;
type?: OverwriteType;
}
export interface PartialRoleData extends RoleData {
id?: Snowflake | number;
}
export enum Partials { export enum Partials {
User, User,
Channel, Channel,