Skip to content

Commit

Permalink
Consistent widget disabled error
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake committed Aug 18, 2024
1 parent f7f16db commit 67d028f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/api/routes/guilds/#guild_id/widget.json.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { random, route } from "@spacebar/api";
import { Channel, Guild, Invite, Member, Permissions } from "@spacebar/util";
import {
Channel,
DiscordApiErrors,
Guild,
Invite,
Member,
Permissions,
} from "@spacebar/util";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server";

const router: Router = Router();

Expand Down Expand Up @@ -48,7 +54,7 @@ router.get(
const { guild_id } = req.params;

const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
if (!guild.widget_enabled) throw new HTTPError("Widget Disabled", 404);
if (!guild.widget_enabled) throw DiscordApiErrors.EMBED_DISABLED;

// Fetch existing widget invite for widget channel
let invite = await Invite.findOne({
Expand Down
10 changes: 5 additions & 5 deletions src/api/routes/guilds/#guild_id/widget.png.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
Copyright (C) 2023 Spacebar and Spacebar Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* eslint-disable @typescript-eslint/no-explicit-any */

import { route } from "@spacebar/api";
import { Guild } from "@spacebar/util";
import { DiscordApiErrors, Guild } from "@spacebar/util";
import { Request, Response, Router } from "express";
import fs from "fs";
import { HTTPError } from "lambert-server";
Expand Down Expand Up @@ -48,7 +48,7 @@ router.get(
const { guild_id } = req.params;

const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
if (!guild.widget_enabled) throw new HTTPError("Unknown Guild", 404);
if (!guild.widget_enabled) throw DiscordApiErrors.EMBED_DISABLED;

// Fetch guild information
const icon = guild.icon;
Expand Down

0 comments on commit 67d028f

Please sign in to comment.