feat: add very large guild feature (#88)
This commit is contained in:
parent
68e90f6a06
commit
aa4e5b0385
@ -457,6 +457,8 @@ pub const feature_disallow_unclaimed_accounts = GuildFeature(
|
|||||||
|
|
||||||
pub const feature_large_guild_override = GuildFeature("LARGE_GUILD_OVERRIDE")
|
pub const feature_large_guild_override = GuildFeature("LARGE_GUILD_OVERRIDE")
|
||||||
|
|
||||||
|
pub const feature_very_large_guild = GuildFeature("VERY_LARGE_GUILD")
|
||||||
|
|
||||||
pub fn get_guild_features() -> List(GuildFeature) {
|
pub fn get_guild_features() -> List(GuildFeature) {
|
||||||
[
|
[
|
||||||
feature_animated_icon,
|
feature_animated_icon,
|
||||||
@ -478,6 +480,7 @@ pub fn get_guild_features() -> List(GuildFeature) {
|
|||||||
feature_expression_purge_allowed,
|
feature_expression_purge_allowed,
|
||||||
feature_disallow_unclaimed_accounts,
|
feature_disallow_unclaimed_accounts,
|
||||||
feature_large_guild_override,
|
feature_large_guild_override,
|
||||||
|
feature_very_large_guild,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,8 @@ export const MAX_GUILD_STICKERS = 50;
|
|||||||
export const MAX_GUILD_STICKERS_MORE_STICKERS = 250;
|
export const MAX_GUILD_STICKERS_MORE_STICKERS = 250;
|
||||||
export const MAX_GUILD_INVITES = 1000;
|
export const MAX_GUILD_INVITES = 1000;
|
||||||
export const MAX_GUILD_ROLES = 250;
|
export const MAX_GUILD_ROLES = 250;
|
||||||
|
export const MAX_GUILD_MEMBERS = 1000;
|
||||||
|
export const MAX_GUILD_MEMBERS_VERY_LARGE = 10000;
|
||||||
|
|
||||||
export const MAX_WEBHOOKS_PER_CHANNEL = 15;
|
export const MAX_WEBHOOKS_PER_CHANNEL = 15;
|
||||||
export const MAX_WEBHOOKS_PER_GUILD = 1000;
|
export const MAX_WEBHOOKS_PER_GUILD = 1000;
|
||||||
|
|||||||
@ -71,6 +71,7 @@ export const GuildFeatures = {
|
|||||||
VISIONARY: 'VISIONARY',
|
VISIONARY: 'VISIONARY',
|
||||||
OPERATOR: 'OPERATOR',
|
OPERATOR: 'OPERATOR',
|
||||||
LARGE_GUILD_OVERRIDE: 'LARGE_GUILD_OVERRIDE',
|
LARGE_GUILD_OVERRIDE: 'LARGE_GUILD_OVERRIDE',
|
||||||
|
VERY_LARGE_GUILD: 'VERY_LARGE_GUILD',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const GuildSplashCardAlignment = {
|
export const GuildSplashCardAlignment = {
|
||||||
|
|||||||
@ -19,12 +19,21 @@
|
|||||||
|
|
||||||
import type {GuildID, RoleID, UserID} from '~/BrandedTypes';
|
import type {GuildID, RoleID, UserID} from '~/BrandedTypes';
|
||||||
import {createChannelID, createRoleID} from '~/BrandedTypes';
|
import {createChannelID, createRoleID} from '~/BrandedTypes';
|
||||||
import {MAX_GUILDS_NON_PREMIUM, MAX_GUILDS_PREMIUM, Permissions, SystemChannelFlags} from '~/Constants';
|
import {
|
||||||
|
GuildFeatures,
|
||||||
|
MAX_GUILD_MEMBERS,
|
||||||
|
MAX_GUILD_MEMBERS_VERY_LARGE,
|
||||||
|
MAX_GUILDS_NON_PREMIUM,
|
||||||
|
MAX_GUILDS_PREMIUM,
|
||||||
|
Permissions,
|
||||||
|
SystemChannelFlags,
|
||||||
|
} from '~/Constants';
|
||||||
import type {ChannelService} from '~/channel/services/ChannelService';
|
import type {ChannelService} from '~/channel/services/ChannelService';
|
||||||
import {AuditLogActionType} from '~/constants/AuditLogActionType';
|
import {AuditLogActionType} from '~/constants/AuditLogActionType';
|
||||||
import {JoinSourceTypes} from '~/constants/Guild';
|
import {JoinSourceTypes} from '~/constants/Guild';
|
||||||
import {
|
import {
|
||||||
InputValidationError,
|
InputValidationError,
|
||||||
|
MaxGuildMembersError,
|
||||||
MaxGuildsError,
|
MaxGuildsError,
|
||||||
MissingPermissionsError,
|
MissingPermissionsError,
|
||||||
UnknownGuildError,
|
UnknownGuildError,
|
||||||
@ -437,6 +446,13 @@ export class GuildMemberOperationsService {
|
|||||||
const user = await this.userRepository.findUnique(userId);
|
const user = await this.userRepository.findUnique(userId);
|
||||||
if (!user) throw new UnknownGuildError();
|
if (!user) throw new UnknownGuildError();
|
||||||
|
|
||||||
|
const maxGuildMembers = guild.features.has(GuildFeatures.VERY_LARGE_GUILD)
|
||||||
|
? MAX_GUILD_MEMBERS_VERY_LARGE
|
||||||
|
: MAX_GUILD_MEMBERS;
|
||||||
|
if (guild.memberCount >= maxGuildMembers) {
|
||||||
|
throw new MaxGuildMembersError(maxGuildMembers);
|
||||||
|
}
|
||||||
|
|
||||||
if (!skipBanCheck) {
|
if (!skipBanCheck) {
|
||||||
await this.validationService.checkUserBanStatus({userId, guildId});
|
await this.validationService.checkUserBanStatus({userId, guildId});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,16 @@ import {
|
|||||||
type UserID,
|
type UserID,
|
||||||
vanityCodeToInviteCode,
|
vanityCodeToInviteCode,
|
||||||
} from '~/BrandedTypes';
|
} from '~/BrandedTypes';
|
||||||
import {ChannelTypes, GuildFeatures, GuildOperations, InviteTypes, MAX_GUILD_INVITES, Permissions} from '~/Constants';
|
import {
|
||||||
|
ChannelTypes,
|
||||||
|
GuildFeatures,
|
||||||
|
GuildOperations,
|
||||||
|
InviteTypes,
|
||||||
|
MAX_GUILD_INVITES,
|
||||||
|
MAX_GUILD_MEMBERS,
|
||||||
|
MAX_GUILD_MEMBERS_VERY_LARGE,
|
||||||
|
Permissions,
|
||||||
|
} from '~/Constants';
|
||||||
import type {ChannelService} from '~/channel/services/ChannelService';
|
import type {ChannelService} from '~/channel/services/ChannelService';
|
||||||
import {AuditLogActionType} from '~/constants/AuditLogActionType';
|
import {AuditLogActionType} from '~/constants/AuditLogActionType';
|
||||||
import {
|
import {
|
||||||
@ -422,8 +431,11 @@ export class InviteService {
|
|||||||
await this.guildService.checkUserBanStatus({userId, guildId: invite.guildId});
|
await this.guildService.checkUserBanStatus({userId, guildId: invite.guildId});
|
||||||
|
|
||||||
const {memberCount} = await this.gatewayService.getGuildCounts(invite.guildId);
|
const {memberCount} = await this.gatewayService.getGuildCounts(invite.guildId);
|
||||||
if (memberCount >= 1000) {
|
const maxGuildMembers = guild.features.has(GuildFeatures.VERY_LARGE_GUILD)
|
||||||
throw new MaxGuildMembersError(1000);
|
? MAX_GUILD_MEMBERS_VERY_LARGE
|
||||||
|
: MAX_GUILD_MEMBERS;
|
||||||
|
if (memberCount >= maxGuildMembers) {
|
||||||
|
throw new MaxGuildMembersError(maxGuildMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invite.temporary) {
|
if (invite.temporary) {
|
||||||
|
|||||||
@ -50,6 +50,8 @@ export const MAX_GUILD_EMOJIS_ANIMATED_MORE_EMOJI = 250;
|
|||||||
export const MAX_GUILD_EMOJIS_STATIC_MORE_EMOJI = 250;
|
export const MAX_GUILD_EMOJIS_STATIC_MORE_EMOJI = 250;
|
||||||
export const MAX_GUILD_STICKERS = 50;
|
export const MAX_GUILD_STICKERS = 50;
|
||||||
export const MAX_GUILD_STICKERS_MORE_STICKERS = 250;
|
export const MAX_GUILD_STICKERS_MORE_STICKERS = 250;
|
||||||
|
export const MAX_GUILD_MEMBERS = 1000;
|
||||||
|
export const MAX_GUILD_MEMBERS_VERY_LARGE = 10000;
|
||||||
export const MAX_CHANNELS_PER_CATEGORY = 50;
|
export const MAX_CHANNELS_PER_CATEGORY = 50;
|
||||||
|
|
||||||
export const MAX_MESSAGE_LENGTH_PREMIUM = 4000;
|
export const MAX_MESSAGE_LENGTH_PREMIUM = 4000;
|
||||||
@ -639,6 +641,7 @@ export const GuildFeatures = {
|
|||||||
OPERATOR: 'OPERATOR',
|
OPERATOR: 'OPERATOR',
|
||||||
DISALLOW_UNCLAIMED_ACCOUNTS: 'DISALLOW_UNCLAIMED_ACCOUNTS',
|
DISALLOW_UNCLAIMED_ACCOUNTS: 'DISALLOW_UNCLAIMED_ACCOUNTS',
|
||||||
LARGE_GUILD_OVERRIDE: 'LARGE_GUILD_OVERRIDE',
|
LARGE_GUILD_OVERRIDE: 'LARGE_GUILD_OVERRIDE',
|
||||||
|
VERY_LARGE_GUILD: 'VERY_LARGE_GUILD',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const JumpTypes = {
|
export const JumpTypes = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user