Filter vocal chanel for web page

This commit is contained in:
BrokenFire 2018-02-26 12:09:56 +01:00
parent 4cb83c8725
commit 1917a2c944
2 changed files with 45 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import net.Broken.RestApi.Data.UserManager.UserInfoData;
import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException;
import net.Broken.Tools.UserManager.Exceptions.UserNotFoundException;
import net.Broken.Tools.UserManager.UserRegister;
import net.Broken.audio.FindGeneral;
import net.Broken.audio.NotConectedException;
import net.Broken.audio.NullMusicManager;
import net.dv8tion.jda.core.entities.VoiceChannel;
@ -116,7 +117,7 @@ public class MusicWebAPIController {
@RequestMapping(value = "/getChanel", method = RequestMethod.GET)
public List<Chanel> getChanel(){
List<Chanel> temp = new ArrayList<>();
for(VoiceChannel aChanel : MainBot.jda.getVoiceChannels()){
for(VoiceChannel aChanel : FindGeneral.find(MainBot.jda.getGuilds().get(0)).getVoiceChannels()){
temp.add(new Chanel(aChanel.getName(),aChanel.getId(),aChanel.getPosition()));
}
return temp;

View File

@ -0,0 +1,43 @@
package net.Broken.audio;
import net.dv8tion.jda.core.entities.Category;
import net.dv8tion.jda.core.entities.Channel;
import net.dv8tion.jda.core.entities.Guild;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
public class FindGeneral {
static Logger logger = LogManager.getLogger();
public static Category find(Guild guild){
List<Category> categories = guild.getCategories();
Category finded = null;
for(Category cat : categories){
if(cat.getName().contains("\uD83E\uDD16")){
finded = cat;
break;
}
}
if(finded == null)
finded = create(guild);
return finded;
}
private static Category create(Guild guild){
logger.info("Can't find general voice chanel, creating it!");
Channel temp = guild.getController().createCategory("\uD83E\uDD16 Salons Vocaux \uD83E\uDD16").complete();
Category cat = guild.getCategoryById(temp.getId());
cat.createVoiceChannel("Général").complete();
cat.createVoiceChannel("Cour").complete();
cat.createVoiceChannel("\uD83C\uDFAE Game 1 \uD83C\uDFAE").complete();
cat.createVoiceChannel("\uD83C\uDFAE Game 2 \uD83C\uDFAE").complete();
cat.createVoiceChannel("\uD83C\uDFAE Game 3 \uD83C\uDFAE").complete();
cat.createVoiceChannel("AFK").complete();
cat = guild.getCategoryById(temp.getId());
return cat;
}
}