Skip to content

Commit

Permalink
feat(application): ✨ Check if user is on Discord
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Feb 11, 2024
1 parent 74bbf83 commit ab4dbdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/controllers/ApplicationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ class ApplicationController {
ERROR_NO_PERMISSION(res);
}

if (!(await this.core.getDiscord().isOnServer(req.user.discordId))) {
ERROR_GENERIC(
res,
428,
"Please join the BuildTheEarth.net Discord Server"
);
return;
}

let buildteam = await this.core.getPrisma().buildTeam.findUnique({
where: req.query.slug ? { slug: req.params.id } : { id: req.params.id },
select: {
Expand Down
8 changes: 8 additions & 0 deletions src/util/DiscordIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ class DiscordIntegration {
}).then((res) => res.json());
}

public async isOnServer(user: string) {
const res = await this.getBuilderRole(user);
if (res?.error == "NOT_FOUND") {
return false;
}
return true;
}

public async sendClaimUpdate(claim: Claim) {
return this.sendRawWebhook({
embeds: [
Expand Down

0 comments on commit ab4dbdc

Please sign in to comment.