Skip to content

Commit

Permalink
Merge pull request #1 from suggestionsbot/docs/errors
Browse files Browse the repository at this point in the history
📝 Add in documentation for reading errors
  • Loading branch information
acollierr17 authored Oct 2, 2022
2 parents 9e2c084 + e7a8086 commit 4c2b179
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 0 deletions.
176 changes: 176 additions & 0 deletions docs/errors.mdx
Original file line number Diff line number Diff line change
@@ -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.
<ErrorEmbed title="Command failed" description="Looks like this suggestion was deleted." code={1} />

### 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.
<ErrorEmbed
title="Missing Permissions"
description={
<>
I need the following permissions in order to run this command.
<br /><br />
Missing permissions edit suggestions in your suggestions channel
<br /><br />
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.
<ErrorEmbed
title="Missing Suggestions Channel"
description={
<>
This command requires a suggestion channel to use.
<br /><br />
Please contact an administrator and ask them to set one up using the
following command.
<br /><br />
<DiscordInlineCode>/config channel</DiscordInlineCode>
</>
}
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.
<ErrorEmbed
title="Missing Suggestions Channel"
description={
<>
This command requires a log channel to use.
<br /><br />
Please contact an administrator and ask them to set one up using the following command.
<br /><br />
<DiscordInlineCode>/config logs</DiscordInlineCode>
</>
}
code={4} />

### Suggestion Not Found
This error is thrown when the bot is unable to find a suggestion with the given ID.
<ErrorEmbed title="Command failed" description="No suggestion exists with this id." code={5} />

### Owner Only
This error is thrown when attempting to run a command which is only available to the bot owners.
<ErrorEmbed title="Command failed" description="You do not have permission to run this command." code={6} />


### 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.
<ErrorEmbed title="Command failed" description="Your suggestion content was too long, please limit it to 1000 characters or less." code={7} />

### Invalid Guild Config Choice
This error is thrown when trying to view an invalid configuration choice.
<ErrorEmbed title="Command failed" description="The provided guild config choice doesn't exist." code={8} />

### Command On Cooldown
This error is thrown when the bot is on cooldown for a command.
<ErrorEmbed title="Command on Cooldown" description="Ahh man so fast! You must wait 3 seconds to run this command again" code={9} />

### 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.
<ErrorEmbed
title="Unknown message"
description={
<>
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.
<ErrorEmbed
title="Something went wrong"
description={
<>
Please contact support.
<br /><br />
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.
<ErrorEmbed
title="Command failed"
description={
<>
I've failed to find something, please retry whatever you were doing.
<br /><br />
If this error persists, please contact support.
<br /><br />
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.
<ErrorEmbed
title="Configuration Error"
description={
<>
I cannot find your configured channel for this command.
<br /><br />
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.
<ErrorEmbed title="Configuration Error" description="I do not have permission to use your guilds configured suggestions channel." code={14} />

### Missing Permissions In Logs Channel
This error is thrown when the bot doesn't have permissions to use the configured suggestions logs channel.
<ErrorEmbed title="Configuration Error" description="I do not have permission to use your guilds configured logs channel." code={15} />

### Missing Translation
This error is thrown when attempting to translate a nonexistent localization key.
<ErrorEmbed
title="Something went wrong"
description={
<>
Please contact support.
<br /><br />
Guild ID: 601219766258106399
</>
}
code={16} />
35 changes: 35 additions & 0 deletions src/components/Embeds/ErrorEmbed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 (
<div className='padding-bottom--md'>
<DiscordMessages>
<DiscordMessage profile='suggestions' ephemeral>
<DiscordEmbed
slot='embeds'
color={EmbedColor.ERROR}
embedTitle={title}>
<DiscordEmbedDescription slot='description'>
{description}
</DiscordEmbedDescription>
<DiscordEmbedFooter slot='footer' timestamp={new Date()}>
Error code {code} | Cluster 1
</DiscordEmbedFooter>
</DiscordEmbed>
</DiscordMessage>
</DiscordMessages>
</div>
);
}
26 changes: 26 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ 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,
CONFIGURED_CHANNEL_NO_LONGER_EXISTS = 13,
MISSING_PERMISSIONS_IN_SUGGESTIONS_CHANNEL = 14,
MISSING_PERMISSIONS_IN_LOGS_CHANNEL = 15,
MISSING_TRANSLATION = 16,
}

export type EmbedProps = {
Expand All @@ -12,3 +32,9 @@ export type EmbedProps = {
displayEmbedAuthor?: boolean;
ephemeral?: boolean;
};

export type ErrorEmbedProps = {
title: string;
description: string | JSX.Element;
code: ErrorCode;
};

1 comment on commit 4c2b179

@vercel
Copy link

@vercel vercel bot commented on 4c2b179 Oct 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.