Merge pull request #1186 from DEVTomatoCake/fix/consistent-widget-disabled-error
Consistent widget disabled error
This commit is contained in:
commit
20637ffdea
@ -1,25 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
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
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU Affero General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { random, route } from "@spacebar/api";
|
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 { Request, Response, Router } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
|
||||||
|
|
||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
@ -48,7 +54,7 @@ router.get(
|
|||||||
const { guild_id } = req.params;
|
const { guild_id } = req.params;
|
||||||
|
|
||||||
const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
|
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
|
// Fetch existing widget invite for widget channel
|
||||||
let invite = await Invite.findOne({
|
let invite = await Invite.findOne({
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import { route } from "@spacebar/api";
|
import { route } from "@spacebar/api";
|
||||||
import { Guild } from "@spacebar/util";
|
import { DiscordApiErrors, Guild } from "@spacebar/util";
|
||||||
import { Request, Response, Router } from "express";
|
import { Request, Response, Router } from "express";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
@ -49,7 +49,7 @@ router.get(
|
|||||||
const { guild_id } = req.params;
|
const { guild_id } = req.params;
|
||||||
|
|
||||||
const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
|
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
|
// Fetch guild information
|
||||||
const icon = "avatars/" + guild_id + "/" + guild.icon;
|
const icon = "avatars/" + guild_id + "/" + guild.icon;
|
||||||
|
@ -812,7 +812,7 @@ export const DiscordApiErrors = {
|
|||||||
"Cannot execute action on a DM channel",
|
"Cannot execute action on a DM channel",
|
||||||
50003,
|
50003,
|
||||||
),
|
),
|
||||||
EMBED_DISABLED: new ApiError("Guild widget disabled", 50004),
|
EMBED_DISABLED: new ApiError("Widget Disabled", 50004),
|
||||||
CANNOT_EDIT_MESSAGE_BY_OTHER: new ApiError(
|
CANNOT_EDIT_MESSAGE_BY_OTHER: new ApiError(
|
||||||
"Cannot edit a message authored by another user",
|
"Cannot edit a message authored by another user",
|
||||||
50005,
|
50005,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user