From e134459ca2bc7c72e3629bb13f46c8ed3f0b5936 Mon Sep 17 00:00:00 2001 From: SebClem Date: Fri, 3 Jun 2022 14:28:12 +0200 Subject: [PATCH] :hammer: Add invite link api --- .../java/net/Broken/Api/Controllers/GuildController.java | 9 +++++++++ src/main/java/net/Broken/Api/Data/InviteLink.java | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 src/main/java/net/Broken/Api/Data/InviteLink.java diff --git a/src/main/java/net/Broken/Api/Controllers/GuildController.java b/src/main/java/net/Broken/Api/Controllers/GuildController.java index 444d7b2..7c4efdd 100644 --- a/src/main/java/net/Broken/Api/Controllers/GuildController.java +++ b/src/main/java/net/Broken/Api/Controllers/GuildController.java @@ -1,8 +1,11 @@ package net.Broken.Api.Controllers; import net.Broken.Api.Data.Guild; +import net.Broken.Api.Data.InviteLink; import net.Broken.Api.Security.Data.JwtPrincipal; import net.Broken.Api.Services.GuildService; +import net.Broken.MainBot; +import net.dv8tion.jda.api.Permission; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -27,4 +30,10 @@ public class GuildController { JwtPrincipal jwtPrincipal = (JwtPrincipal) authentication.getPrincipal(); return guildService.getMutualGuilds(jwtPrincipal.user()); } + + @GetMapping("inviteLink") + public InviteLink getInviteLink(){ + String link = MainBot.jda.getInviteUrl(Permission.ADMINISTRATOR); + return new InviteLink(link); + } } diff --git a/src/main/java/net/Broken/Api/Data/InviteLink.java b/src/main/java/net/Broken/Api/Data/InviteLink.java new file mode 100644 index 0000000..f98926d --- /dev/null +++ b/src/main/java/net/Broken/Api/Data/InviteLink.java @@ -0,0 +1,4 @@ +package net.Broken.Api.Data; + +public record InviteLink(String link) { +}