Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: discord - revive bot #100

Merged
merged 7 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"start": "pnpm --filter main start",
"dev": "pnpm --filter main start-pretty",
"discord:deploy-commands": "pnpm --filter main discord:deploy-commands",
"test": "vitest",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
Expand Down
9 changes: 5 additions & 4 deletions packages/bot-utils/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Response } from 'got';
import { codeBlock } from './response.js';

interface APIError {
error: {
Expand All @@ -25,7 +26,9 @@ export class PostError extends Error {

export function getAPIErrorMessage (error: unknown): string {
// @ts-expect-error Discord error format
if (error.code === 50_001) { return 'Missing access! Please add the Globalping bot to this channel!'; }
if (error.code === 50_001) {
return 'Missing access! Please add the Globalping bot to this channel!';
}

if (error instanceof PostError) {
const { location, response } = error;
Expand Down Expand Up @@ -57,8 +60,6 @@ export function getAPIErrorMessage (error: unknown): string {
}

export function formatAPIError (error: unknown): string {
return `\`\`\`
${getAPIErrorMessage(error)}
\`\`\`
return `${codeBlock(getAPIErrorMessage(error))}
Documentation and Support: https://github.com/jsdelivr/globalping`;
}
Loading
Loading