🔨 Add textchannel and voicechannel endpoint
This commit is contained in:
parent
47fa3ae2bf
commit
3f5225bef1
@ -2,15 +2,14 @@ package net.Broken.Api.Controllers;
|
|||||||
|
|
||||||
import net.Broken.Api.Data.Guild;
|
import net.Broken.Api.Data.Guild;
|
||||||
import net.Broken.Api.Data.InviteLink;
|
import net.Broken.Api.Data.InviteLink;
|
||||||
|
import net.Broken.Api.Data.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;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -36,4 +35,17 @@ public class GuildController {
|
|||||||
String link = MainBot.jda.getInviteUrl(Permission.ADMINISTRATOR);
|
String link = MainBot.jda.getInviteUrl(Permission.ADMINISTRATOR);
|
||||||
return new InviteLink(link);
|
return new InviteLink(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/{guildId}/voiceChannels")
|
||||||
|
@PreAuthorize("isInGuild(#guildId)")
|
||||||
|
public List<Channel> getVoiceChannels(@PathVariable String guildId){
|
||||||
|
return guildService.getVoiceChannel(String.valueOf(guildId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{guildId}/textChannels")
|
||||||
|
@PreAuthorize("isInGuild(#guildId)")
|
||||||
|
public List<Channel> getTextChannels(@PathVariable String guildId){
|
||||||
|
return guildService.getTextChannel(String.valueOf(guildId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirements;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirements;
|
||||||
import net.Broken.Api.Security.Data.JwtPrincipal;
|
import net.Broken.Api.Security.Data.JwtPrincipal;
|
||||||
import net.Broken.DB.Entity.UserEntity;
|
import net.Broken.DB.Entity.UserEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
4
src/main/java/net/Broken/Api/Data/Channel.java
Normal file
4
src/main/java/net/Broken/Api/Data/Channel.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package net.Broken.Api.Data;
|
||||||
|
|
||||||
|
public record Channel(String id, String name) {
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package net.Broken.Api.Services;
|
package net.Broken.Api.Services;
|
||||||
|
|
||||||
import net.Broken.Api.Data.Guild;
|
import net.Broken.Api.Data.Guild;
|
||||||
|
import net.Broken.Api.Data.Channel;
|
||||||
import net.Broken.DB.Entity.UserEntity;
|
import net.Broken.DB.Entity.UserEntity;
|
||||||
|
import net.Broken.MainBot;
|
||||||
import net.Broken.Tools.CacheTools;
|
import net.Broken.Tools.CacheTools;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -22,4 +24,23 @@ public class GuildService {
|
|||||||
return guildList;
|
return guildList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Channel> getVoiceChannel(String guildId){
|
||||||
|
net.dv8tion.jda.api.entities.Guild guild = MainBot.jda.getGuildById(guildId);
|
||||||
|
|
||||||
|
List<Channel> voiceChannels = new ArrayList<>();
|
||||||
|
for(net.dv8tion.jda.api.entities.VoiceChannel voiceChannel : guild.getVoiceChannels()){
|
||||||
|
voiceChannels.add(new Channel(voiceChannel.getId(), voiceChannel.getName()));
|
||||||
|
}
|
||||||
|
return voiceChannels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Channel> getTextChannel(String guildId){
|
||||||
|
net.dv8tion.jda.api.entities.Guild guild = MainBot.jda.getGuildById(guildId);
|
||||||
|
List<Channel> voiceChannels = new ArrayList<>();
|
||||||
|
for(net.dv8tion.jda.api.entities.TextChannel textChannel : guild.getTextChannels()){
|
||||||
|
voiceChannels.add(new Channel(textChannel.getId(), textChannel.getName()));
|
||||||
|
}
|
||||||
|
return voiceChannels;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<Appenders>
|
<Appenders>
|
||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<!--<PatternLayout pattern="[%d{HH:mm:ss.SSS}][%-5level][%-30.30c{1.}]: %msg%n" />-->
|
<!--<PatternLayout pattern="[%d{HH:mm:ss.SSS}][%-5level][%-30.30c{1.}]: %msg%n" />-->
|
||||||
<PatternLayout>
|
<PatternLayout disableAnsi="false">
|
||||||
<Pattern>[%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow ,
|
<Pattern>[%d{HH:mm:ss.SSS}]%highlight{[%-5level]}{FATAL=red blink, ERROR=red, WARN=bright yellow ,
|
||||||
INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink,
|
INFO=blue, DEBUG=bright black, TRACE=cyan}[%-30.30c{1.}]: %highlight{%msg%n}{FATAL=red blink,
|
||||||
ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}
|
ERROR=red, WARN=bright yellow , INFO=blue, DEBUG=bright black, TRACE=cyan}
|
||||||
|
Loading…
Reference in New Issue
Block a user