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

what the hell erkin #1104

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
55 changes: 0 additions & 55 deletions src/api/routes/guilds/#guild_id/bans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,58 +178,6 @@
},
);

router.put(
"/@me",
route({
requestBody: "BanCreateSchema",
responses: {
200: {
body: "Ban",
},
400: {
body: "APIErrorResponse",
},
403: {
body: "APIErrorResponse",
},
},
}),
async (req: Request, res: Response) => {
const { guild_id } = req.params;

const banned_user = await User.getPublicUser(req.params.user_id);

if (req.permission?.cache.guild?.owner_id === req.params.user_id)
throw new HTTPError(
"You are the guild owner, hence can't ban yourself",
403,
);

const ban = Ban.create({
user_id: req.params.user_id,
guild_id: guild_id,
ip: getIpAdress(req),
executor_id: req.params.user_id,
reason: req.body.reason, // || otherwise empty
});

await Promise.all([
Member.removeFromGuild(req.user_id, guild_id),
ban.save(),
emitEvent({
event: "GUILD_BAN_ADD",
data: {
guild_id: guild_id,
user: banned_user,
},
guild_id: guild_id,
} as GuildBanAddEvent),
]);

return res.json(ban);
},
);

router.delete(
"/:user_id",
route({
Expand All @@ -247,13 +195,10 @@
async (req: Request, res: Response) => {
const { guild_id, user_id } = req.params;

const ban = await Ban.findOneOrFail({

Check warning on line 198 in src/api/routes/guilds/#guild_id/bans.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'ban' is assigned a value but never used
where: { guild_id: guild_id, user_id: user_id },
});

if (ban.user_id === ban.executor_id) throw DiscordApiErrors.UNKNOWN_BAN;
// make self-bans irreversible and hide them from view to avoid victim chasing

const banned_user = await User.getPublicUser(user_id);

await Promise.all([
Expand Down