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.Tools.AntiSpam;
|
||||
import net.Broken.Tools.Command.CommandParser;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.Broken.Tools.Moderateur;
|
||||
import net.Broken.Tools.PrivateMessage;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
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.guild.member.GuildMemberJoinEvent;
|
||||
import net.dv8tion.jda.core.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||
@ -85,38 +88,48 @@ public class BotListener extends ListenerAdapter {
|
||||
public void onMessageReceived(MessageReceivedEvent event) {
|
||||
// ----------------------Test pour eviter eco de commande-------------------------
|
||||
|
||||
if (event.getMessage().getContent().startsWith("//") && !event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
|
||||
//On a detecter que c'etait une commande
|
||||
//System.out.println(event.getMessage().getContent());
|
||||
MainBot.handleCommand(new CommandParser().parse(event.getMessage().getContent(), event));
|
||||
|
||||
}
|
||||
else if (!event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId()))
|
||||
{
|
||||
try{
|
||||
if (event.getMessage().getContent().startsWith("//") && !event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) {
|
||||
//On a detecter que c'etait une commande
|
||||
//System.out.println(event.getMessage().getContent());
|
||||
MainBot.handleCommand(new CommandParser().parse(event.getMessage().getContent(), event));
|
||||
|
||||
if(!event.isFromType(ChannelType.PRIVATE)) {
|
||||
if (!event.getTextChannel().getName().equals("le_dongeon")) {
|
||||
Guild serveur = event.getGuild();
|
||||
GuildManager guildManager = serveur.getManager();
|
||||
Member user = event.getMember();
|
||||
|
||||
// appel de la methode d'analyse de message de "Moderateur"
|
||||
if (!event.getAuthor().getName().equals("Aethex") && event.getMessage().getContent().length() > 0) {
|
||||
|
||||
if (modo.analyse(user, serveur, guildManager, event) == 1) {
|
||||
antispam.extermine(user, serveur, guildManager, true, event);
|
||||
}
|
||||
} else if (event.getMessage().getContent().length() == 0)
|
||||
logger.error("Image detected, ignoring it.");
|
||||
|
||||
}
|
||||
}
|
||||
else if (!event.getMessage().getAuthor().getId().equals(event.getJDA().getSelfUser().getId()))
|
||||
{
|
||||
|
||||
if(!event.isFromType(ChannelType.PRIVATE)) {
|
||||
if (!event.getTextChannel().getName().equals("le_dongeon")) {
|
||||
Guild serveur = event.getGuild();
|
||||
GuildManager guildManager = serveur.getManager();
|
||||
Member user = event.getMember();
|
||||
|
||||
// appel de la methode d'analyse de message de "Moderateur"
|
||||
if (!event.getAuthor().getName().equals("Aethex") && event.getMessage().getContent().length() > 0) {
|
||||
|
||||
if (modo.analyse(user, serveur, guildManager, event) == 1) {
|
||||
antispam.extermine(user, serveur, guildManager, true, event);
|
||||
}
|
||||
} else if (event.getMessage().getContent().length() == 0)
|
||||
logger.error("Image detected, ignoring it.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}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
|
||||
{
|
||||
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()) {
|
||||
if(!e.getValue().isAdminCmd() || event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
||||
if(!e.getValue().isAdminCmd() || isAdmin)
|
||||
txt.append("\n- ").append(e.getKey());
|
||||
}
|
||||
|
||||
@ -131,7 +139,7 @@ public class Help implements Commande {
|
||||
|
||||
|
||||
String role;
|
||||
if(event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
||||
if(isAdmin)
|
||||
role = "Admin";
|
||||
else
|
||||
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.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;
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
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);
|
||||
return buildStandar(temp);
|
||||
return temp;
|
||||
|
||||
|
||||
}
|
||||
@ -85,7 +85,7 @@ public class EmbedMessageUtils {
|
||||
}
|
||||
|
||||
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){
|
||||
@ -95,7 +95,7 @@ public class EmbedMessageUtils {
|
||||
}
|
||||
|
||||
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){
|
||||
|
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),
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
Cookies.set('token',data.token);
|
||||
Cookies.set('name', data.name);
|
||||
Cookies.set('token',data.token, { expires: 31 });
|
||||
Cookies.set('name', data.name, { expires: 31 });
|
||||
debugger;
|
||||
location.reload();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user