Skip to content

Commit

Permalink
feat: add new errors for handling HTTP errors (#6)
Browse files Browse the repository at this point in the history
* feat: add new errors

* feat: fix table

* fix: table hyperlink

* feat: add MISSING_THREAD_CREATE_PERMISSIONS

* chore: update error embed

* chore: update error embed

* chore: update error embed
  • Loading branch information
Skelmis authored Jan 28, 2023
1 parent c441877 commit f026cf8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
55 changes: 36 additions & 19 deletions docs/errors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@ 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) |
| 17 | SUGGESTION_RESOLUTION_ERROR | [click](#suggestion-resolution-error) |
| 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_FETCH_PERMISSIONS_IN_SUGGESTIONS_CHANNEL | [click](#missing-permissions-in-suggestions-channel) |
| 15 | MISSING_FETCH_PERMISSIONS_IN_LOGS_CHANNEL | [click](#missing-permissions-in-logs-channel) |
| 16 | MISSING_TRANSLATION | [click](#missing-translation) |
| 17 | SUGGESTION_RESOLUTION_ERROR | [click](#suggestion-resolution-error) |
| 18 | MISSING_SEND_PERMISSIONS_IN_SUGGESTION_CHANNEL | [click](#missing-send-permissions-in-suggestions-channel) |
| 19 | MISSING_THREAD_CREATE_PERMISSIONS | [click](#missing thread create permissions) |

## Error Information

Expand Down Expand Up @@ -203,3 +205,18 @@ This error is thrown when something goes wrong while attempting to either approv
</>
}
code={17} />


### Missing send permissions in suggestions channel

This error is thrown when the bot is missing permissions to send messages in your suggestions channel.
<ErrorEmbed title="Configuration Error" description="I do not have permission to send messages in your guilds suggestion channel." code={18} />


### Missing thread create permissions

This error is thrown when the bot cannot create threads in your suggestions channel.
<ErrorEmbed
title="Missing permissions"
description="I am unable to create threads in your suggestions channel, please contact an administrator and ask them to give me 'Create Public Threads' permissions.\n\nAlternatively, ask your administrator to disable automatic thread creation using `/config thread disable`"
code={19} />
6 changes: 4 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export enum ErrorCode {
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_FETCH_PERMISSIONS_IN_SUGGESTIONS_CHANNEL = 14,
MISSING_FETCH_PERMISSIONS_IN_LOGS_CHANNEL = 15,
MISSING_TRANSLATION = 16,
SUGGESTION_RESOLUTION_ERROR = 17,
MISSING_SEND_PERMISSIONS_IN_SUGGESTION_CHANNEL = 18,
MISSING_THREAD_CREATE_PERMISSIONS = 19
}

export type EmbedProps = {
Expand Down

1 comment on commit f026cf8

@vercel
Copy link

@vercel vercel bot commented on f026cf8 Jan 28, 2023

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.