From 39b5ad094c8866a27688d9a5d637d3bbf88748c3 Mon Sep 17 00:00:00 2001 From: Dominik Koch Date: Mon, 19 Aug 2024 23:11:59 +0200 Subject: [PATCH] feat(system-message): add upgrade type (#450) * feat(system-message): add upgrade type * fix: remove extra pin --- packages/core/demo/index.html | 1 + .../DiscordSystemMessage.ts | 12 +++++++----- .../core/src/components/svgs/ServerUpgrade.ts | 15 +++++++++++++++ .../lit/components/DiscordComponentsWrapper.ts | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 packages/core/src/components/svgs/ServerUpgrade.ts diff --git a/packages/core/demo/index.html b/packages/core/demo/index.html index 4875fb1de..469d71e4c 100644 --- a/packages/core/demo/index.html +++ b/packages/core/demo/index.html @@ -373,6 +373,7 @@

System Messages

Favna pinned a message to this channel. See all pinned messages. + Dominik upgraded Skyra to premium for this server! 🎉 Warning! Warning! This library is the coolest of them all! Error! Cool overload!. diff --git a/packages/core/src/components/discord-system-message/DiscordSystemMessage.ts b/packages/core/src/components/discord-system-message/DiscordSystemMessage.ts index abc980ee0..160292401 100644 --- a/packages/core/src/components/discord-system-message/DiscordSystemMessage.ts +++ b/packages/core/src/components/discord-system-message/DiscordSystemMessage.ts @@ -10,6 +10,7 @@ import DMCall from '../svgs/DMCall.js'; import DMEdit from '../svgs/DMEdit.js'; import DMMissedCall from '../svgs/DMMissedCall.js'; import Pin from '../svgs/Pin.js'; +import ServerUpgrade from '../svgs/ServerUpgrade.js'; import SystemAlert from '../svgs/SystemAlert.js'; import SystemError from '../svgs/SystemError.js'; import Thread from '../svgs/Thread.js'; @@ -151,10 +152,10 @@ export class DiscordSystemMessage extends LitElement implements LightTheme { /** * The type of system message this is, this will change the icon shown. - * Valid values: `join`, `leave`, `call`, `missed-call`, `boost`, `edit`, `thread`, `pin`, `alert`, and `error`. + * Valid values: `join`, `leave`, `call`, `missed-call`, `boost`, `edit`, `thread`, `pin`, `alert`, `upgrade` and `error`. */ @property({ reflect: true, attribute: 'type' }) - public accessor type: 'alert' | 'boost' | 'call' | 'edit' | 'error' | 'join' | 'leave' | 'missed-call' | 'pin' | 'thread' = 'join'; + public accessor type: 'alert' | 'boost' | 'call' | 'edit' | 'error' | 'join' | 'leave' | 'missed-call' | 'pin' | 'thread' | 'upgrade' = 'join'; /** * Whether this message is to show channel name changes, used to match Discord's style. @@ -172,9 +173,9 @@ export class DiscordSystemMessage extends LitElement implements LightTheme { public checkType() { if (typeof this.type !== 'string') { throw new TypeError('DiscordSystemMessage `type` prop must be a string.'); - } else if (!['join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'error'].includes(this.type)) { + } else if (!['join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'error', 'upgrade'].includes(this.type)) { throw new RangeError( - "DiscordSystemMessage `type` prop must be one of: 'join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'error'" + "DiscordSystemMessage `type` prop must be one of: 'join', 'leave', 'call', 'missed-call', 'boost', 'edit', 'thread', 'pin', 'alert', 'upgrade', 'error'" ); } } @@ -200,7 +201,8 @@ export class DiscordSystemMessage extends LitElement implements LightTheme { ['thread', () => Thread()], ['pin', () => Pin()], ['alert', () => SystemAlert()], - ['error', () => SystemError()] + ['error', () => SystemError()], + ['upgrade', () => ServerUpgrade()] ])}
diff --git a/packages/core/src/components/svgs/ServerUpgrade.ts b/packages/core/src/components/svgs/ServerUpgrade.ts new file mode 100644 index 000000000..6bfa6efb9 --- /dev/null +++ b/packages/core/src/components/svgs/ServerUpgrade.ts @@ -0,0 +1,15 @@ +import { html, svg } from 'lit'; +import { spread } from '../../spread.js'; + +const svgContent = svg` + +`; + +export default function ServerUpgrade(props: Record = {}) { + return html`${svgContent}`; +} diff --git a/packages/documentation/src/lit/components/DiscordComponentsWrapper.ts b/packages/documentation/src/lit/components/DiscordComponentsWrapper.ts index 8a9f81cc5..a29c67e8c 100644 --- a/packages/documentation/src/lit/components/DiscordComponentsWrapper.ts +++ b/packages/documentation/src/lit/components/DiscordComponentsWrapper.ts @@ -358,6 +358,7 @@ export class DiscordComponentsWrapper extends LitElement { Favna pinned a message to this channel. See all pinned messages. + Dominik upgraded Skyra to premium for this server! 🎉 Warning! Warning! This library is the coolest of them all! Error! Cool overload!.