feat: add announcement channels, publishing and following (#3090)

This commit is contained in:
Hampus
2026-10-01 16:57:21 +02:00
committed by GitHub
parent 376afd2ad6
commit 7e4d5137f8
381 changed files with 45650 additions and 14076 deletions
+18
View File
@@ -40,6 +40,7 @@ fn generate_admin_api(manifest_dir: &Path, out_dir: &Path) {
adapt_progenitor_throttled_errors(&mut spec);
relax_guild_audit_log_schemas(&mut spec);
relax_progenitor_schema_strictness(&mut spec);
relax_integer_enums(&mut spec);
let mut settings = progenitor::GenerationSettings::new();
settings.with_interface(progenitor::InterfaceStyle::Positional);
@@ -174,6 +175,23 @@ fn relax_guild_audit_log_schemas(spec: &mut openapiv3::OpenAPI) {
}
}
const OPEN_INTEGER_ENUMS: &[&str] = &["ChannelType", "MessageType", "WebhookType"];
fn relax_integer_enums(spec: &mut openapiv3::OpenAPI) {
let components = spec.components.as_mut().expect("missing API components");
for name in OPEN_INTEGER_ENUMS {
let Some(openapiv3::ReferenceOr::Item(schema)) = components.schemas.get_mut(*name) else {
panic!("missing inline {name} schema");
};
let openapiv3::SchemaKind::Type(openapiv3::Type::Integer(integer)) =
&mut schema.schema_kind
else {
panic!("{name} must be an integer schema");
};
integer.enumeration.clear();
}
}
fn object_schema_mut<'a>(
components: &'a mut openapiv3::Components,
name: &str,
+32 -9
View File
@@ -13287,7 +13287,7 @@
"ChannelType": {
"description": "The type of the channel",
"type": "integer",
"enum": [0, 1, 2, 3, 4, 998, 999],
"enum": [0, 1, 2, 3, 4, 5, 998, 999],
"format": "int32",
"x-enumNames": [
"GUILD_TEXT",
@@ -13295,6 +13295,7 @@
"GUILD_VOICE",
"GROUP_DM",
"GUILD_CATEGORY",
"GUILD_ANNOUNCEMENT",
"GUILD_LINK",
"DM_PERSONAL_NOTES"
],
@@ -13304,6 +13305,7 @@
"A voice channel within a guild",
"A group direct message between users",
"A category that contains channels",
"A guild channel whose messages can be published to channels that follow it",
"A link channel for external resources",
"Personal notes DM channel"
]
@@ -13502,7 +13504,7 @@
"enum": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
},
"GuildFeatureSchema": {
"description": "A guild feature flag Known values: ANIMATED_ICON, ANIMATED_BANNER, AUDIO_BITRATE_128_KBPS, AUDIO_BITRATE_256_KBPS, AUDIO_BITRATE_384_KBPS, BANNER, CLONE_EMOJI_DISABLED, CLONE_EMOJI_ENABLED, CLONE_STICKER_DISABLED, CLONE_STICKER_ENABLED, DETACHED_BANNER, INVITE_SPLASH, INVITES_DISABLED, RAID_DETECTED, TEXT_CHANNEL_FLEXIBLE_NAMES, HIDE_OWNER_CROWN, MORE_EMOJI, MORE_STICKERS, UNLIMITED_EMOJI, UNLIMITED_STICKERS, EXPRESSION_PURGE_ALLOWED, VANITY_URL, DISCOVERABLE, PARTNERED, VERIFIED, VIP_VOICE, VOICE_E2EE, UNAVAILABLE_FOR_EVERYONE, UNAVAILABLE_FOR_EVERYONE_BUT_STAFF, UNAVAILABLE_HIDDEN, VISIONARY, LARGE_GUILD_OVERRIDE, VERY_LARGE_GUILD (other values allowed)",
"description": "A guild feature flag Known values: ANIMATED_ICON, ANIMATED_BANNER, AUDIO_BITRATE_128_KBPS, AUDIO_BITRATE_256_KBPS, AUDIO_BITRATE_384_KBPS, BANNER, CLONE_EMOJI_DISABLED, CLONE_EMOJI_ENABLED, CLONE_STICKER_DISABLED, CLONE_STICKER_ENABLED, DETACHED_BANNER, INVITE_SPLASH, INVITES_DISABLED, RAID_DETECTED, TEXT_CHANNEL_FLEXIBLE_NAMES, HIDE_OWNER_CROWN, MORE_EMOJI, MORE_STICKERS, UNLIMITED_EMOJI, UNLIMITED_STICKERS, EXPRESSION_PURGE_ALLOWED, VANITY_URL, DISCOVERABLE, PARTNERED, VERIFIED, VIP_VOICE, VOICE_E2EE, UNAVAILABLE_FOR_EVERYONE, UNAVAILABLE_FOR_EVERYONE_BUT_STAFF, UNAVAILABLE_HIDDEN, VISIONARY, LARGE_GUILD_OVERRIDE, VERY_LARGE_GUILD, ANNOUNCEMENT_CHANNELS_DISABLED (other values allowed)",
"x-enumNames": [
"ANIMATED_ICON",
"ANIMATED_BANNER",
@@ -13536,7 +13538,8 @@
"UNAVAILABLE_HIDDEN",
"VISIONARY",
"LARGE_GUILD_OVERRIDE",
"VERY_LARGE_GUILD"
"VERY_LARGE_GUILD",
"ANNOUNCEMENT_CHANNELS_DISABLED"
],
"x-enumDescriptions": [
"Guild can have an animated icon",
@@ -13571,7 +13574,8 @@
"Guild is hidden when it is force unavailable",
"Guild is a visionary guild",
"Guild has large guild overrides enabled",
"Guild has increased member capacity enabled"
"Guild has increased member capacity enabled",
"Guild cannot publish announcement messages or gain new followers"
],
"type": "string"
},
@@ -13738,7 +13742,8 @@
"allOf": [{"$ref": "#/components/schemas/SnowflakeStringType"}]
},
"message_id": {
"description": "The ID of the referenced message",
"description": "The ID of the referenced message, absent on a channel follow system message",
"nullable": true,
"allOf": [{"$ref": "#/components/schemas/SnowflakeStringType"}]
},
"guild_id": {
@@ -13748,7 +13753,7 @@
},
"type": {"allOf": [{"$ref": "#/components/schemas/MessageReferenceType"}]}
},
"required": ["channel_id", "message_id", "type"],
"required": ["channel_id", "type"],
"additionalProperties": false
},
"message_snapshots": {
@@ -13883,7 +13888,8 @@
"allOf": [{"$ref": "#/components/schemas/SnowflakeStringType"}]
},
"message_id": {
"description": "The ID of the referenced message",
"description": "The ID of the referenced message, absent on a channel follow system message",
"nullable": true,
"allOf": [{"$ref": "#/components/schemas/SnowflakeStringType"}]
},
"guild_id": {
@@ -13893,7 +13899,7 @@
},
"type": {"allOf": [{"$ref": "#/components/schemas/MessageReferenceType"}]}
},
"required": ["channel_id", "message_id", "type"],
"required": ["channel_id", "type"],
"additionalProperties": false
},
"message_snapshots": {
@@ -14384,11 +14390,26 @@
"description": "The bitwise flags of the original message",
"format": "int32",
"x-bitflagValues": [
{
"name": "CROSSPOSTED",
"value": "1",
"description": "This message has been published to channels that follow this announcement channel"
},
{
"name": "IS_CROSSPOST",
"value": "2",
"description": "This message was delivered from an announcement channel this channel follows"
},
{
"name": "SUPPRESS_EMBEDS",
"value": "4",
"description": "Do not include embeds when serialising this message"
},
{
"name": "SOURCE_MESSAGE_DELETED",
"value": "8",
"description": "The published message this copy came from has been deleted"
},
{
"name": "SUPPRESS_NOTIFICATIONS",
"value": "4096",
@@ -14400,7 +14421,7 @@
"MessageType": {
"description": "The type of message",
"type": "integer",
"enum": [0, 1, 2, 3, 4, 5, 6, 7, 19],
"enum": [0, 1, 2, 3, 4, 5, 6, 7, 12, 19],
"format": "int32",
"x-enumNames": [
"DEFAULT",
@@ -14411,6 +14432,7 @@
"CHANNEL_ICON_CHANGE",
"CHANNEL_PINNED_MESSAGE",
"USER_JOIN",
"CHANNEL_FOLLOW_ADD",
"REPLY"
],
"x-enumDescriptions": [
@@ -14422,6 +14444,7 @@
"A system message indicating the channel icon changed",
"A system message indicating a message was pinned",
"A system message indicating a user joined",
"System message posted when a channel starts following an announcement channel",
"A reply message"
]
},
@@ -179,6 +179,7 @@ const GUILD_FEATURES: &[&str] = &[
"VISIONARY",
"LARGE_GUILD_OVERRIDE",
"VERY_LARGE_GUILD",
"ANNOUNCEMENT_CHANNELS_DISABLED",
];
const DEPRECATED_GUILD_FEATURES: &[&str] = &["CLONE_EMOJI_DISABLED", "CLONE_STICKER_DISABLED"];
@@ -45,6 +45,7 @@ const GUILD_FEATURES: &[&str] = &[
"VISIONARY",
"LARGE_GUILD_OVERRIDE",
"VERY_LARGE_GUILD",
"ANNOUNCEMENT_CHANNELS_DISABLED",
];
const HOSTED_ONLY: &[&str] = &["VISIONARY", "VIP_VOICE"];
@@ -32,6 +32,7 @@ fn channel_type_label(channel_type: i32) -> &'static str {
0 => "Text",
2 => "Voice",
4 => "Category",
5 => "Announcement",
13 => "Link",
_ => "Unknown",
}