Merge branch 'devel'
This commit is contained in:
commit
fec75ccd2b
@ -4,11 +4,14 @@ import net.Broken.Commands.Move;
|
|||||||
import net.Broken.Commands.Music;
|
import net.Broken.Commands.Music;
|
||||||
import net.Broken.Tools.AntiSpam;
|
import net.Broken.Tools.AntiSpam;
|
||||||
import net.Broken.Tools.Command.CommandParser;
|
import net.Broken.Tools.Command.CommandParser;
|
||||||
|
import net.Broken.Tools.EmbedMessageUtils;
|
||||||
import net.Broken.Tools.Moderateur;
|
import net.Broken.Tools.Moderateur;
|
||||||
|
import net.Broken.Tools.PrivateMessage;
|
||||||
import net.dv8tion.jda.core.entities.ChannelType;
|
import net.dv8tion.jda.core.entities.ChannelType;
|
||||||
import net.dv8tion.jda.core.entities.Guild;
|
import net.dv8tion.jda.core.entities.Guild;
|
||||||
import net.dv8tion.jda.core.entities.Member;
|
import net.dv8tion.jda.core.entities.Member;
|
||||||
import net.dv8tion.jda.core.entities.TextChannel;
|
import net.dv8tion.jda.core.entities.TextChannel;
|
||||||
|
import net.dv8tion.jda.core.events.ExceptionEvent;
|
||||||
import net.dv8tion.jda.core.events.ReadyEvent;
|
import net.dv8tion.jda.core.events.ReadyEvent;
|
||||||
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
|
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
|
||||||
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleRemoveEvent;
|
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||||
@ -85,6 +88,8 @@ public class BotListener extends ListenerAdapter {
|
|||||||
public void onMessageReceived(MessageReceivedEvent event) {
|
public void onMessageReceived(MessageReceivedEvent event) {
|
||||||
// ----------------------Test pour eviter eco de commande-------------------------
|
// ----------------------Test pour eviter eco de commande-------------------------
|
||||||
|
|
||||||
|
|
||||||
|
try{
|
||||||
if (event.getMessage().getContent().startsWith("//") && !event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
|
if (event.getMessage().getContent().startsWith("//") && !event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
|
||||||
//On a detecter que c'etait une commande
|
//On a detecter que c'etait une commande
|
||||||
//System.out.println(event.getMessage().getContent());
|
//System.out.println(event.getMessage().getContent());
|
||||||
@ -113,10 +118,18 @@ public class BotListener extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.catching(e);
|
||||||
|
|
||||||
|
if(event.isFromType(ChannelType.PRIVATE))
|
||||||
|
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getInternalError(), logger);
|
||||||
|
else
|
||||||
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
41
src/main/java/net/Broken/Commands/Error.java
Normal file
41
src/main/java/net/Broken/Commands/Error.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package net.Broken.Commands;
|
||||||
|
|
||||||
|
import net.Broken.Commande;
|
||||||
|
import net.Broken.Tools.EmbedMessageUtils;
|
||||||
|
import net.Broken.Tools.PrivateMessage;
|
||||||
|
import net.dv8tion.jda.core.entities.ChannelType;
|
||||||
|
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public class Error implements Commande{
|
||||||
|
|
||||||
|
private Logger logger = LogManager.getLogger();
|
||||||
|
@Override
|
||||||
|
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(String[] args, MessageReceivedEvent event) {
|
||||||
|
if(event.isFromType(ChannelType.PRIVATE))
|
||||||
|
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getInternalError(), logger);
|
||||||
|
else
|
||||||
|
event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executed(boolean success, MessageReceivedEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPrivateUsable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAdminCmd() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -115,8 +115,16 @@ public class Help implements Commande {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder txt= new StringBuilder();
|
StringBuilder txt= new StringBuilder();
|
||||||
|
|
||||||
|
boolean isAdmin;
|
||||||
|
if(event.isFromType(ChannelType.PRIVATE))
|
||||||
|
isAdmin = event.getJDA().getGuilds().get(0).getMember(event.getAuthor()).hasPermission(Permission.ADMINISTRATOR);
|
||||||
|
else
|
||||||
|
isAdmin = event.getMember().hasPermission(Permission.ADMINISTRATOR);
|
||||||
|
|
||||||
|
|
||||||
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
|
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
|
||||||
if(!e.getValue().isAdminCmd() || event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
if(!e.getValue().isAdminCmd() || isAdmin)
|
||||||
txt.append("\n- ").append(e.getKey());
|
txt.append("\n- ").append(e.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +139,7 @@ public class Help implements Commande {
|
|||||||
|
|
||||||
|
|
||||||
String role;
|
String role;
|
||||||
if(event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
if(isAdmin)
|
||||||
role = "Admin";
|
role = "Admin";
|
||||||
else
|
else
|
||||||
role = "Non Admin";
|
role = "Non Admin";
|
||||||
|
@ -13,6 +13,7 @@ import net.Broken.RestApi.Data.UserManager.UserInfoData;
|
|||||||
import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException;
|
import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException;
|
||||||
import net.Broken.Tools.UserManager.Exceptions.UserNotFoundException;
|
import net.Broken.Tools.UserManager.Exceptions.UserNotFoundException;
|
||||||
import net.Broken.Tools.UserManager.UserRegister;
|
import net.Broken.Tools.UserManager.UserRegister;
|
||||||
|
import net.Broken.audio.FindGeneral;
|
||||||
import net.Broken.audio.NotConectedException;
|
import net.Broken.audio.NotConectedException;
|
||||||
import net.Broken.audio.NullMusicManager;
|
import net.Broken.audio.NullMusicManager;
|
||||||
import net.dv8tion.jda.core.entities.VoiceChannel;
|
import net.dv8tion.jda.core.entities.VoiceChannel;
|
||||||
@ -116,7 +117,7 @@ public class MusicWebAPIController {
|
|||||||
@RequestMapping(value = "/getChanel", method = RequestMethod.GET)
|
@RequestMapping(value = "/getChanel", method = RequestMethod.GET)
|
||||||
public List<Chanel> getChanel(){
|
public List<Chanel> getChanel(){
|
||||||
List<Chanel> temp = new ArrayList<>();
|
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()));
|
temp.add(new Chanel(aChanel.getName(),aChanel.getId(),aChanel.getPosition()));
|
||||||
}
|
}
|
||||||
return temp;
|
return temp;
|
||||||
|
@ -15,9 +15,9 @@ public class EmbedMessageUtils {
|
|||||||
return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
public static MessageEmbed getError(String message) {
|
public static EmbedBuilder getError(String message) {
|
||||||
EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message);
|
EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message);
|
||||||
return buildStandar(temp);
|
return temp;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ public class EmbedMessageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MessageEmbed getInternalError(){
|
public static MessageEmbed getInternalError(){
|
||||||
return getError("Je... Je... je ne me sent pas bien... :thermometer_face: \nContactez vite mon developeur!");
|
return buildStandar(getError("Je... Je... je ne me sens pas bien... :thermometer_face: \nContactez vite mon developeur!").setImage("https://media.giphy.com/media/Rkis28kMJd1aE/giphy.gif"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageEmbed buildStandar(EmbedBuilder embedBuilder){
|
public static MessageEmbed buildStandar(EmbedBuilder embedBuilder){
|
||||||
@ -95,7 +95,7 @@ public class EmbedMessageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MessageEmbed getUnautorized(){
|
public static MessageEmbed getUnautorized(){
|
||||||
return getError("Vous n'avez pas l'autorisation de faire ça!");
|
return buildStandar(getError("Vous n'avez pas l'autorisation de faire ça!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageEmbed getHelpList(String role, String list){
|
public static MessageEmbed getHelpList(String role, String list){
|
||||||
|
43
src/main/java/net/Broken/audio/FindGeneral.java
Normal file
43
src/main/java/net/Broken/audio/FindGeneral.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -85,8 +85,8 @@ function tryConnection() {
|
|||||||
data: JSON.stringify(request),
|
data: JSON.stringify(request),
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
Cookies.set('token',data.token);
|
Cookies.set('token',data.token, { expires: 31 });
|
||||||
Cookies.set('name', data.name);
|
Cookies.set('name', data.name, { expires: 31 });
|
||||||
debugger;
|
debugger;
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user