1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-13 22:23:47 +01:00
This commit is contained in:
Madeline 2024-06-05 15:17:20 +10:00
parent ea523d06b7
commit a3a28f522f
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
4 changed files with 16 additions and 11 deletions

View File

@ -109,7 +109,7 @@ router.get(
const banInfo = { const banInfo = {
user: await User.getPublicUser(ban.user_id), user: await User.getPublicUser(ban.user_id),
reason: ban.reason, reason: ban.reason,
} };
return res.json(banInfo); return res.json(banInfo);
}, },

View File

@ -51,10 +51,12 @@ router.post(
const { guild_id } = req.params; const { guild_id } = req.params;
const userIds: Array<string> = req.body.user_ids; const userIds: Array<string> = req.body.user_ids;
if (!userIds) if (!userIds) throw new HTTPError("The user_ids array is missing", 400);
throw new HTTPError("The user_ids array is missing", 400);
if (userIds.length > 200) if (userIds.length > 200)
throw new HTTPError("The user_ids array must be between 1 and 200 in length", 400); throw new HTTPError(
"The user_ids array must be between 1 and 200 in length",
400,
);
const banned_users = []; const banned_users = [];
const failed_users = []; const failed_users = [];
@ -116,8 +118,12 @@ router.post(
} }
} }
if (banned_users.length === 0 && failed_users.length > 0) throw DiscordApiErrors.BULK_BAN_FAILED; if (banned_users.length === 0 && failed_users.length > 0)
return res.json({ banned_users: banned_users, failed_users: failed_users }); throw DiscordApiErrors.BULK_BAN_FAILED;
return res.json({
banned_users: banned_users,
failed_users: failed_users,
});
}, },
); );

View File

@ -96,7 +96,9 @@ export function route(opts: RouteOptions) {
req.params.channel_id, req.params.channel_id,
); );
const requiredPerms = Array.isArray(opts.permission) ? opts.permission : [opts.permission]; const requiredPerms = Array.isArray(opts.permission)
? opts.permission
: [opts.permission];
requiredPerms.forEach((perm) => { requiredPerms.forEach((perm) => {
// bitfield comparison: check if user lacks certain permission // bitfield comparison: check if user lacks certain permission
if (!req.permission!.has(new Permissions(perm))) { if (!req.permission!.has(new Permissions(perm))) {

View File

@ -1003,10 +1003,7 @@ export const DiscordApiErrors = {
"Message was blocked by automatic moderation", "Message was blocked by automatic moderation",
200000, 200000,
), ),
BULK_BAN_FAILED: new ApiError( BULK_BAN_FAILED: new ApiError("Failed to ban users", 500000),
"Failed to ban users",
500000
),
//Other errors //Other errors
UNKNOWN_VOICE_STATE: new ApiError("Unknown Voice State", 10065, 404), UNKNOWN_VOICE_STATE: new ApiError("Unknown Voice State", 10065, 404),