🔨 Add getRole endpoint
This commit is contained in:
parent
2cd22ab2db
commit
4677b95822
@ -1,8 +1,9 @@
|
|||||||
package net.Broken.Api.Controllers;
|
package net.Broken.Api.Controllers;
|
||||||
|
|
||||||
import net.Broken.Api.Data.Guild;
|
import net.Broken.Api.Data.Guild.Guild;
|
||||||
|
import net.Broken.Api.Data.Guild.Role;
|
||||||
import net.Broken.Api.Data.InviteLink;
|
import net.Broken.Api.Data.InviteLink;
|
||||||
import net.Broken.Api.Data.Channel;
|
import net.Broken.Api.Data.Guild.Channel;
|
||||||
import net.Broken.Api.Security.Data.JwtPrincipal;
|
import net.Broken.Api.Security.Data.JwtPrincipal;
|
||||||
import net.Broken.Api.Services.GuildService;
|
import net.Broken.Api.Services.GuildService;
|
||||||
import net.Broken.MainBot;
|
import net.Broken.MainBot;
|
||||||
@ -40,12 +41,18 @@ public class GuildController {
|
|||||||
@GetMapping("/{guildId}/voiceChannels")
|
@GetMapping("/{guildId}/voiceChannels")
|
||||||
@PreAuthorize("isInGuild(#guildId)")
|
@PreAuthorize("isInGuild(#guildId)")
|
||||||
public List<Channel> getVoiceChannels(@PathVariable String guildId){
|
public List<Channel> getVoiceChannels(@PathVariable String guildId){
|
||||||
return guildService.getVoiceChannel(String.valueOf(guildId));
|
return guildService.getVoiceChannel(guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{guildId}/textChannels")
|
@GetMapping("/{guildId}/textChannels")
|
||||||
@PreAuthorize("isInGuild(#guildId)")
|
@PreAuthorize("isInGuild(#guildId)")
|
||||||
public List<Channel> getTextChannels(@PathVariable String guildId){
|
public List<Channel> getTextChannels(@PathVariable String guildId){
|
||||||
return guildService.getTextChannel(String.valueOf(guildId));
|
return guildService.getTextChannel(guildId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{guildId}/roles")
|
||||||
|
@PreAuthorize("isInGuild(#guildId)")
|
||||||
|
public List<Role> getRoles(@PathVariable String guildId){
|
||||||
|
return guildService.getRole(guildId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.Broken.Api.Data;
|
package net.Broken.Api.Data.Guild;
|
||||||
|
|
||||||
public record Channel(String id, String name) {
|
public record Channel(String id, String name) {
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.Broken.Api.Data;
|
package net.Broken.Api.Data.Guild;
|
||||||
|
|
||||||
public record Guild(String id, String name, String iconUrl) {
|
public record Guild(String id, String name, String iconUrl) {
|
||||||
}
|
}
|
4
src/main/java/net/Broken/Api/Data/Guild/Role.java
Normal file
4
src/main/java/net/Broken/Api/Data/Guild/Role.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package net.Broken.Api.Data.Guild;
|
||||||
|
|
||||||
|
public record Role(String id, String name) {
|
||||||
|
}
|
@ -1,7 +1,8 @@
|
|||||||
package net.Broken.Api.Services;
|
package net.Broken.Api.Services;
|
||||||
|
|
||||||
import net.Broken.Api.Data.Guild;
|
import net.Broken.Api.Data.Guild.Guild;
|
||||||
import net.Broken.Api.Data.Channel;
|
import net.Broken.Api.Data.Guild.Channel;
|
||||||
|
import net.Broken.Api.Data.Guild.Role;
|
||||||
import net.Broken.DB.Entity.UserEntity;
|
import net.Broken.DB.Entity.UserEntity;
|
||||||
import net.Broken.MainBot;
|
import net.Broken.MainBot;
|
||||||
import net.Broken.Tools.CacheTools;
|
import net.Broken.Tools.CacheTools;
|
||||||
@ -43,4 +44,15 @@ public class GuildService {
|
|||||||
return voiceChannels;
|
return voiceChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Role> getRole(String guildId){
|
||||||
|
net.dv8tion.jda.api.entities.Guild guild = MainBot.jda.getGuildById(guildId);
|
||||||
|
List<Role> roles = new ArrayList<>();
|
||||||
|
for(net.dv8tion.jda.api.entities.Role role : guild.getRoles()){
|
||||||
|
if(!role.isManaged()){
|
||||||
|
roles.add(new Role(role.getId(), role.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user