From 2add2574fb2ed3f84668997836c57afcb6eb962b Mon Sep 17 00:00:00 2001 From: Anthony Collier Date: Thu, 4 Aug 2022 01:13:05 -0400 Subject: [PATCH 1/6] :construction: Build out errors page with UI components --- docs/errors.md | 61 ++++++++++++++++++++++++++++ src/components/Embeds/ErrorEmbed.tsx | 32 +++++++++++++++ src/constants.ts | 22 ++++++++++ 3 files changed, 115 insertions(+) create mode 100644 docs/errors.md create mode 100644 src/components/Embeds/ErrorEmbed.tsx diff --git a/docs/errors.md b/docs/errors.md new file mode 100644 index 0000000..25c27aa --- /dev/null +++ b/docs/errors.md @@ -0,0 +1,61 @@ +--- +sidebar_position: 5 +title: Error Codes +description: Find more information on various error codes the bot can provide and what to do about it. +--- +import ErrorEmbed from '@site/src/components/Embeds/ErrorEmbed'; + +## Table +| Code | Name | Guide | +|------|-----------------------------|---------------------------------------| +| 1 | SUGGESTION_MESSAGE_DELETED | [click](#suggestion-message-deleted) | +| 2 | MISSING_PERMISSIONS | [click](#missing-permissions) | +| 3 | MISSING_SUGGESTIONS_CHANNEL | [click](#missing-suggestions-channel) | +| 4 | MISSING_LOG_CHANNEL | [click](#missing-log-channel) | +| 5 | SUGGESTION_NOT_FOUND | [click](#suggestion-not-found) | +| 6 | OWNER_ONLY | [click](#owner-only) | +| 7 | SUGGESTION_CONTENT_TOO_LONG | [click](#suggestion-content-too-long) | +| 8 | INVALID_GUILD_CONFIG_CHOICE | [click](#invalid-guild-config-choice) | +| 9 | COMMAND_ON_COOLDOWN | [click](#command-on-cooldown) | +| 10 | GENERIC_FORBIDDEN | [click](#generic-forbidden) | +| 11 | UNHANDLED_ERROR | [click](#unhandled-error) | +| 12 | GENERIC_NOT_FOUND | [click](#generic-not-found) | + +## Error Information + +### Suggestion Message Deleted +This error is thrown when attempting to manage a suggestion which it's corresponding message has been deleted. + + +### Missing Permissions +This error is thrown when the bot is missing permissions to perform an action. + +### Missing Suggestions Channel +This error is thrown when the bot is missing a configured suggestions channel. + +### Missing Log Channel +This error is thrown when the bot is missing a configured suggestions log channel. + +### Suggestion Not Found +This error is thrown when the bot is unable to find a suggestion with the given ID. + +### Owner Only +This error is thrown when the bot is unable to perform an action which is only available to the bot owners. + +### Suggestion Content Too Long +This error is thrown when the bot is unable to submit a suggestion with a content length greater than the configured maximum. + +### Invalid Guild Config Choice +This error is thrown when trying to provide an invalid configuration choice. + +### Command On Cooldown +This error is thrown when the bot is on cooldown for a command. + +### Generic Forbidden +This error is thrown as a generic response when the bot is forbidden from performing an action. + +### Unhandled Error +This error is thrown when the bot is unable to handle an error. + +### Generic Not Found +This error is thrown as a generic response when the bot is unable to find an item. diff --git a/src/components/Embeds/ErrorEmbed.tsx b/src/components/Embeds/ErrorEmbed.tsx new file mode 100644 index 0000000..217b3e3 --- /dev/null +++ b/src/components/Embeds/ErrorEmbed.tsx @@ -0,0 +1,32 @@ +import React from 'react'; +import { + DiscordMessages, + DiscordMessage, + DiscordEmbed, + DiscordEmbedDescription, + DiscordEmbedFooter, +} from '@skyra/discord-components-react'; +import { EmbedColor, ErrorEmbedProps } from '../../constants'; + +export default function ErrorEmbed({ + title, + description, + code, +}: ErrorEmbedProps): JSX.Element { + return ( +
+ + + + + {description} + + + Error code {code} | Cluster 1 + + + + +
+ ); +} diff --git a/src/constants.ts b/src/constants.ts index 034983a..2ae4339 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,6 +2,22 @@ export enum EmbedColor { MAIN = '#ffd663', APPROVED = '#00e640', REJECTED = '#cf000f', + ERROR = '#d63031', +} + +export enum ErrorCode { + SUGGESTION_MESSAGE_DELETED = 1, + MISSING_PERMISSIONS = 2, + MISSING_SUGGESTIONS_CHANNEL = 3, + MISSING_LOG_CHANNEL = 4, + SUGGESTION_NOT_FOUND = 5, + OWNER_ONLY = 6, + SUGGESTION_CONTENT_TOO_LONG = 7, + INVALID_GUILD_CONFIG_CHOICE = 8, + COMMAND_ON_COOLDOWN = 9, + GENERIC_FORBIDDEN = 10, + UNHANDLED_ERROR = 11, + GENERIC_NOT_FOUND = 12, } export type EmbedProps = { @@ -12,3 +28,9 @@ export type EmbedProps = { displayEmbedAuthor?: boolean; ephemeral?: boolean; }; + +export type ErrorEmbedProps = { + title: string; + description: string; + code: ErrorCode; +}; From ffa1a95052d0937edb3c8673532ff87b700ed71d Mon Sep 17 00:00:00 2001 From: Anthony Collier Date: Sun, 2 Oct 2022 05:17:02 -0400 Subject: [PATCH 2/6] :memo: Revise based on #1 and add new error codes :truck: Change file type to mdx; :sparkles: Add in error embed components --- docs/errors.md | 61 ----------------- docs/errors.mdx | 176 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 61 deletions(-) delete mode 100644 docs/errors.md create mode 100644 docs/errors.mdx diff --git a/docs/errors.md b/docs/errors.md deleted file mode 100644 index 25c27aa..0000000 --- a/docs/errors.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -sidebar_position: 5 -title: Error Codes -description: Find more information on various error codes the bot can provide and what to do about it. ---- -import ErrorEmbed from '@site/src/components/Embeds/ErrorEmbed'; - -## Table -| Code | Name | Guide | -|------|-----------------------------|---------------------------------------| -| 1 | SUGGESTION_MESSAGE_DELETED | [click](#suggestion-message-deleted) | -| 2 | MISSING_PERMISSIONS | [click](#missing-permissions) | -| 3 | MISSING_SUGGESTIONS_CHANNEL | [click](#missing-suggestions-channel) | -| 4 | MISSING_LOG_CHANNEL | [click](#missing-log-channel) | -| 5 | SUGGESTION_NOT_FOUND | [click](#suggestion-not-found) | -| 6 | OWNER_ONLY | [click](#owner-only) | -| 7 | SUGGESTION_CONTENT_TOO_LONG | [click](#suggestion-content-too-long) | -| 8 | INVALID_GUILD_CONFIG_CHOICE | [click](#invalid-guild-config-choice) | -| 9 | COMMAND_ON_COOLDOWN | [click](#command-on-cooldown) | -| 10 | GENERIC_FORBIDDEN | [click](#generic-forbidden) | -| 11 | UNHANDLED_ERROR | [click](#unhandled-error) | -| 12 | GENERIC_NOT_FOUND | [click](#generic-not-found) | - -## Error Information - -### Suggestion Message Deleted -This error is thrown when attempting to manage a suggestion which it's corresponding message has been deleted. - - -### Missing Permissions -This error is thrown when the bot is missing permissions to perform an action. - -### Missing Suggestions Channel -This error is thrown when the bot is missing a configured suggestions channel. - -### Missing Log Channel -This error is thrown when the bot is missing a configured suggestions log channel. - -### Suggestion Not Found -This error is thrown when the bot is unable to find a suggestion with the given ID. - -### Owner Only -This error is thrown when the bot is unable to perform an action which is only available to the bot owners. - -### Suggestion Content Too Long -This error is thrown when the bot is unable to submit a suggestion with a content length greater than the configured maximum. - -### Invalid Guild Config Choice -This error is thrown when trying to provide an invalid configuration choice. - -### Command On Cooldown -This error is thrown when the bot is on cooldown for a command. - -### Generic Forbidden -This error is thrown as a generic response when the bot is forbidden from performing an action. - -### Unhandled Error -This error is thrown when the bot is unable to handle an error. - -### Generic Not Found -This error is thrown as a generic response when the bot is unable to find an item. diff --git a/docs/errors.mdx b/docs/errors.mdx new file mode 100644 index 0000000..2db711f --- /dev/null +++ b/docs/errors.mdx @@ -0,0 +1,176 @@ +--- +sidebar_position: 5 +title: Error Codes +description: Find more information on various error codes the bot can provide and what to do about it. +--- +import ErrorEmbed from '@site/src/components/Embeds/ErrorEmbed'; +import { DiscordInlineCode } from '@skyra/discord-components-react'; + +## Table +| Code | Name | Guide | +|------|--------------------------------------------|------------------------------------------------------| +| 1 | SUGGESTION_MESSAGE_DELETED | [click](#suggestion-message-deleted) | +| 2 | MISSING_PERMISSIONS | [click](#missing-permissions) | +| 3 | MISSING_SUGGESTIONS_CHANNEL | [click](#missing-suggestions-channel) | +| 4 | MISSING_LOG_CHANNEL | [click](#missing-log-channel) | +| 5 | SUGGESTION_NOT_FOUND | [click](#suggestion-not-found) | +| 6 | OWNER_ONLY | [click](#owner-only) | +| 7 | SUGGESTION_CONTENT_TOO_LONG | [click](#suggestion-content-too-long) | +| 8 | INVALID_GUILD_CONFIG_CHOICE | [click](#invalid-guild-config-choice) | +| 9 | COMMAND_ON_COOLDOWN | [click](#command-on-cooldown) | +| 10 | GENERIC_FORBIDDEN | [click](#generic-forbidden) | +| 11 | UNHANDLED_ERROR | [click](#unhandled-error) | +| 12 | GENERIC_NOT_FOUND | [click](#generic-not-found) | +| 13 | CONFIGURED_CHANNEL_NO_LONGER_EXISTS | [click](#configured-channel-no-longer-exists) | +| 14 | MISSING_PERMISSIONS_IN_SUGGESTIONS_CHANNEL | [click](#missing-permissions-in-suggestions-channel) | +| 15 | MISSING_PERMISSIONS_IN_LOGS_CHANNEL | [click](#missing-permissions-in-logs-channel) | +| 16 | MISSING_TRANSLATION | [click](#missing-translation) | + +## Error Information + +### Suggestion Message Deleted +This error is thrown when attempting to manage a suggestion which its corresponding message has been deleted. + + +### Missing Permissions +This error is thrown when the bot is missing permissions to perform an action, and it knows what permissions are missing. + +The required permissions will be displayed in the error message. + + I need the following permissions in order to run this command. +

+ Missing permissions edit suggestions in your suggestions channel +

+ Please contact an administrator and ask them to provide them for me. + + } + code={2} /> + +### Missing Suggestions Channel +This error is thrown when attempting to run a command which requires a configured suggestions channel, but one does not exist. + + This command requires a suggestion channel to use. +

+ Please contact an administrator and ask them to set one up using the + following command. +

+ /config channel + + } + code={3} /> + +### Missing Log Channel +This error is thrown when attempting to run a command which requires a configured suggestions log channel, but one does not exist. + + This command requires a log channel to use. +

+ Please contact an administrator and ask them to set one up using the following command. +

+ /config logs + + } + code={4} /> + +### Suggestion Not Found +This error is thrown when the bot is unable to find a suggestion with the given ID. + + +### Owner Only +This error is thrown when attempting to run a command which is only available to the bot owners. + + + +### Suggestion Content Too Long +This error is thrown when the bot is unable to submit a suggestion with a content length greater than the configured maximum length of 1,000 characters. + + +### Invalid Guild Config Choice +This error is thrown when trying to view an invalid configuration choice. + + +### Command On Cooldown +This error is thrown when the bot is on cooldown for a command. + + +### Generic Forbidden +This error is thrown as a generic response when the bot is forbidden from performing an action, and it cannot figure out what permissions are missing. + + Looks like something went wrong. + Please make sure I have all the correct permissions in your configured channels. + + } + code={10} /> + +### Unhandled Error +This error is thrown when the bot is unable to handle an error. Please reach out to support if you see this message. + + Please contact support. +

+ Guild ID: 601219766258106399 + + } + code={11} /> + +### Generic Not Found +This error is thrown as a generic response when the bot is unable to find an item. + + I've failed to find something, please retry whatever you were doing. +

+ If this error persists, please contact support. +

+ Guild ID: 601219766258106399 + + } + code={12} /> + +### Configured Channel No Longer Exists +This error is thrown when either the suggestions channel or suggestions logs channel can no longer be found. The error is displayed interchangeably. + + I cannot find your configured channel for this command. +

+ Please ask an administrator to reconfigure one. + + } + code={13} /> + +### Missing Permissions In Suggestions Channel +This error is thrown when the bot doesn't have permissions to use the configured suggestions channel. + + +### Missing Permissions In Logs Channel +This error is thrown when the bot doesn't have permissions to use the configured suggestions logs channel. + + +### Missing Translation +This error is thrown when attempting to translate a nonexistent localization key. + + Please contact support. +

+ Guild ID: 601219766258106399 + + } + code={16} /> From ad49f9ceac81ee4cfcc22ad77826c9d0ea8cfb41 Mon Sep 17 00:00:00 2001 From: Anthony Collier Date: Sun, 2 Oct 2022 05:17:27 -0400 Subject: [PATCH 3/6] :bug: Display embed title --- src/components/Embeds/ErrorEmbed.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/Embeds/ErrorEmbed.tsx b/src/components/Embeds/ErrorEmbed.tsx index 217b3e3..e3a6ec2 100644 --- a/src/components/Embeds/ErrorEmbed.tsx +++ b/src/components/Embeds/ErrorEmbed.tsx @@ -17,7 +17,10 @@ export default function ErrorEmbed({
- + {description} From b85fffd60389288d04b5a797fa4aa65bd971bed7 Mon Sep 17 00:00:00 2001 From: Anthony Collier Date: Sun, 2 Oct 2022 05:17:57 -0400 Subject: [PATCH 4/6] :label: Add enums for new error codes --- src/constants.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 2ae4339..031946d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -18,6 +18,10 @@ export enum ErrorCode { GENERIC_FORBIDDEN = 10, UNHANDLED_ERROR = 11, GENERIC_NOT_FOUND = 12, + CONFIGURED_CHANNEL_NO_LONGER_EXISTS = 13, + MISSING_PERMISSIONS_IN_SUGGESTIONS_CHANNEL = 14, + MISSING_PERMISSIONS_IN_LOGS_CHANNEL = 15, + MISSING_TRANSLATION = 16, } export type EmbedProps = { @@ -31,6 +35,6 @@ export type EmbedProps = { export type ErrorEmbedProps = { title: string; - description: string; + description: string | JSX.Element; code: ErrorCode; }; From ef352a9858784c81fac15db512377465c50f0fab Mon Sep 17 00:00:00 2001 From: Anthony Collier Date: Sun, 2 Oct 2022 05:18:26 -0400 Subject: [PATCH 5/6] :see_no_evil: Add discord components configuration --- .eslintignore | 1 + .prettierignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.eslintignore b/.eslintignore index 071b757..cd310b5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ .eslintrc.js docusaurus.config.js +/modules/discordComponents.js diff --git a/.prettierignore b/.prettierignore index c66be3c..6d7d020 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ docusaurus.config.js +/modules/discordComponents.js From e7a8086cea37f5a56ed16565dceaf3b935756ea5 Mon Sep 17 00:00:00 2001 From: Anthony Collier Date: Sun, 2 Oct 2022 05:22:28 -0400 Subject: [PATCH 6/6] Revert ":see_no_evil: Add discord components configuration" This reverts commit ef352a9858784c81fac15db512377465c50f0fab. --- .eslintignore | 1 - .prettierignore | 1 - 2 files changed, 2 deletions(-) diff --git a/.eslintignore b/.eslintignore index cd310b5..071b757 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,2 @@ .eslintrc.js docusaurus.config.js -/modules/discordComponents.js diff --git a/.prettierignore b/.prettierignore index 6d7d020..c66be3c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1 @@ docusaurus.config.js -/modules/discordComponents.js