Skip to content

Commit

Permalink
Fix changelog link checker + changelog links (#7254)
Browse files Browse the repository at this point in the history
* checkLinks: use frontmatter for changelog anchors

* Fix entitlement migration links

* link to 'in preview' no longer relevant

* Tables 🙃
  • Loading branch information
colinloretz authored Nov 5, 2024
1 parent 462cddc commit 55b4945
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ date: "2024-06-27"
breaking: true
---

Back in March, we announced [the beta for user-installed apps](#DOCS_CHANGE_LOG/user-installable-apps-preview). After listening and making updates based on feedback from developers and modmins, we're excited to announce that user-installed apps are now considered generally available and can be used in all servers (regardless of size).
Back in March, we announced [the beta for user-installed apps](#DOCS_CHANGE_LOG/userinstallable-apps-preview). After listening and making updates based on feedback from developers and modmins, we're excited to announce that user-installed apps are now considered generally available and can be used in all servers (regardless of size).

With this update, there are a few API and behavioral updates for user-installed apps.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ We updated our previous entitlement migration guide to provide more up-to-date i
- The `ends_at` value on the [entitlement object](#DOCS_RESOURCES_ENTITLEMENT/entitlement-object) is set when the subscription ends.
- To receive the value of when a subscription was canceled, you should listen for the `SUBSCRIPTION_UPDATE` events or use the [Subscription API](#DOCS_RESOURCES_SUBSCRIPTION).

View the [updated migration guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration).
View the [updated migration guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api).

To see a full diff of the changes, refer to this pull request: [Entitlement Migration Guide Updates](https://github.com/discord/discord-api-docs/pull/7201).
2 changes: 1 addition & 1 deletion docs/events/Gateway_Events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ Sent when an entitlement is created. The inner payload is an [entitlement](#DOCS
#### Entitlement Update

> danger
> Starting on October 1, 2024, the `ENTITLEMENT_UPDATE` event behavior will be changing. You will no longer receive an `ENTITLEMENT_UPDATE` event on successful renewal When a user cancels, you will receive an `ENTITLEMENT_UPDATE` events with an `ends_at` value when the subscription ends. See the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information.
> Starting on October 1, 2024, the `ENTITLEMENT_UPDATE` event behavior will be changing. You will no longer receive an `ENTITLEMENT_UPDATE` event on successful renewal When a user cancels, you will receive an `ENTITLEMENT_UPDATE` events with an `ends_at` value when the subscription ends. See the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information.
Sent when an entitlement is updated. The inner payload is an [entitlement](#DOCS_RESOURCES_ENTITLEMENT/entitlement-object) object.

Expand Down
6 changes: 3 additions & 3 deletions docs/monetization/Implementing_App_Subscriptions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ When creating subscriptions, you will need to choose between user or guild subsc
## How App Subscriptions Work

> danger
> **Starting on October 1st, 2024**, the`ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information on what is changing and how to prepare.
> **Starting on October 1st, 2024**, the`ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information on what is changing and how to prepare.
- When a user purchases your subscription SKU, Discord creates an [Entitlement](#DOCS_RESOURCES_ENTITLEMENT) for the user (or guild) and that specific Subscription [SKU](#DOCS_RESOURCES_SKU).
- You will receive an `ENTITLEMENT_CREATE` event via the Gateway.
Expand All @@ -39,7 +39,7 @@ When creating subscriptions, you will need to choose between user or guild subsc
- When a user cancels their subscription, your app will not receive any entitlement events.
- When a subscription ends, the entitlement to the subscription will end. Developers will receive an `ENTITLEMENT_UPDATE` event with an `ends_at` timestamp indicating when the subscription ended.

Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information on what is changing and how to prepare.
Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information on what is changing and how to prepare.

### Using Subscription Events for the Subscription Lifecycle

Expand Down Expand Up @@ -73,7 +73,7 @@ Depending on your app's features, you can use a combination of [Gateway events](
### Accessing Entitlements with Gateway Events

> danger
> **Starting on October 1, 2024**, the `ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information on what is changing and how to prepare. The docs will be updated on November 1, 2024 to reflect the new behavior.
> **Starting on October 1, 2024**, the `ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information on what is changing and how to prepare. The docs will be updated on November 1, 2024 to reflect the new behavior.
When users subscribe or renew a subscription with your app, Discord will emit [Entitlement Gateway events](#DOCS_EVENTS_GATEWAY_EVENTS/entitlements).

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/Message.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Represents a message sent in a channel within Discord.
| message_reference? | [message reference](#DOCS_RESOURCES_MESSAGE/message-reference-structure) object | data showing the source of a crosspost, channel follow add, pin, or reply message |
| message_snapshots? \[5\] | array of [message snapshot](#DOCS_RESOURCES_MESSAGE/message-snapshot-object) objects | the message associated with the `message_reference`. This is a minimal subset of fields in a message (e.g. `author` is excluded.) |
| referenced_message? \[4\] | ?[message object](#DOCS_RESOURCES_MESSAGE/message-object) | the message associated with the message_reference |
| interaction_metadata? | [message interaction metadata object](#DOCS_RESOURCES_MESSAGE/message-interaction-metadata-object) | [In preview](#DOCS_CHANGE_LOG/user-installable-apps-preview). Sent if the message is sent as a result of an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) |
| interaction_metadata? | [message interaction metadata object](#DOCS_RESOURCES_MESSAGE/message-interaction-metadata-object) | Sent if the message is sent as a result of an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) |
| interaction? | [message interaction object](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/message-interaction-object-message-interaction-structure) | **Deprecated in favor of `interaction_metadata`**; sent if the message is a response to an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) |
| thread? | [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object | the thread that was started from this message, includes [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object |
| components? \[2\] | array of [message components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/component-object) | sent if the message contains components like buttons, action rows, or other interactive components |
Expand Down
9 changes: 8 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
"@eslint/js": "^9.2.0",
"@mdx-js/mdx": "^3.0.1",
"@mdx-js/react": "^3.0.1",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.12.12",
"chalk": "^5.3.0",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"js-yaml": "^4.1.0",
"markdown-table-formatter": "^1.6.0",
"mdast-util-from-markdown": "^2.0.1",
"mdast-util-to-markdown": "^2.1.0",
Expand Down
19 changes: 18 additions & 1 deletion tools/checkLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import { readdirSync, statSync, readFileSync } from "node:fs";
import path from "node:path";
import chalk from "chalk";
import * as github from "@actions/core";
import * as yaml from "js-yaml";
const cwd = process.env.GITHUB_ACTIONS ? process.env.GITHUB_WORKSPACE! : process.cwd();

interface Frontmatter {
title?: string;
date?: string;
breaking: boolean;
}

function importDirectory(directory: string, extensions: string[], subdirectories = true) {
try {
const output = new Map<string, string>();
Expand Down Expand Up @@ -110,7 +117,17 @@ for (const [name, raw] of docFiles) {
// This collects all potential change-log pages, and adds them to the list of
// available anchors under `/change_log`.
if (name.startsWith("/change_log/")) {
changelogAnchors.push(name.split("/")[2].slice(11));
const frontmatter = raw.split("---")[1];
const parsedFrontmatter = yaml.load(frontmatter) as Frontmatter;
const title = parsedFrontmatter?.title;
if (title) {
const anchor = title
.replace(/[^ A-Z0-9]/gi, "")
.trim()
.replace(/ +/g, "-")
.toLowerCase();
changelogAnchors.push(anchor);
}
}

let parentAnchor = "";
Expand Down

0 comments on commit 55b4945

Please sign in to comment.