Add invite command and Resolve admin on private message

This commit is contained in:
Sebastien 2018-04-29 15:58:41 +02:00
parent 285b87876c
commit c06bdcd21a
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,33 @@
package net.Broken.Commands;
import net.Broken.Commande;
import net.Broken.Tools.PrivateMessage;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.logging.log4j.LogManager;
public class Invite implements Commande{
@Override
public void action(String[] args, MessageReceivedEvent event) {
if(event.getChannelType().isGuild()){
event.getTextChannel().sendMessage("You can invite me whit this link:\nhttps://discordapp.com/oauth2/authorize?client_id=" + event.getJDA().getSelfUser().getId() + "&scope=bot&permissions=8").complete();
}
else {
PrivateMessage.send(event.getAuthor(),"You can invite me whit this link:\nhttps://discordapp.com/oauth2/authorize?client_id=" + event.getJDA().getSelfUser().getId() + "&scope=bot&permissions=8",LogManager.getLogger());
}
}
@Override
public boolean isPrivateUsable() {
return true;
}
@Override
public boolean isAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -112,7 +112,7 @@ public class MainBot {
Commande cmdObj = commandes.get(cmd.commande); Commande cmdObj = commandes.get(cmd.commande);
boolean isAdmin; boolean isAdmin;
if(cmd.event.isFromType(ChannelType.PRIVATE)){ if(cmd.event.isFromType(ChannelType.PRIVATE)){
isAdmin = cmd.event.getGuild().getMember(cmd.event.getAuthor()).hasPermission(Permission.ADMINISTRATOR); isAdmin = false;
} }
else else
isAdmin = cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR); isAdmin = cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR);