Version 1.4.0 merge from development. #6
1
pom.xml
1
pom.xml
|
@ -12,6 +12,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
|
|
|
@ -22,6 +22,7 @@ import sx.blah.discord.util.RateLimitException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrew Lalis
|
* @author Andrew Lalis
|
||||||
|
@ -34,6 +35,8 @@ public class HandieBot {
|
||||||
public static final String APPLICATION_NAME = "HandieBot";
|
public static final String APPLICATION_NAME = "HandieBot";
|
||||||
private static final String TOKEN = "MjgzNjUyOTg5MjEyNjg4Mzg0.C45A_Q.506b0G6my1FEFa7_YY39lxLBHUY";
|
private static final String TOKEN = "MjgzNjUyOTg5MjEyNjg4Mzg0.C45A_Q.506b0G6my1FEFa7_YY39lxLBHUY";
|
||||||
|
|
||||||
|
public static ResourceBundle resourceBundle = ResourceBundle.getBundle("Strings");
|
||||||
|
|
||||||
//Discord client object.
|
//Discord client object.
|
||||||
public static IDiscordClient client;
|
public static IDiscordClient client;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import handiebot.command.commands.support.InfoCommand;
|
||||||
import handiebot.command.types.Command;
|
import handiebot.command.types.Command;
|
||||||
import handiebot.command.types.ContextCommand;
|
import handiebot.command.types.ContextCommand;
|
||||||
import handiebot.command.types.StaticCommand;
|
import handiebot.command.types.StaticCommand;
|
||||||
import handiebot.utils.DisappearingMessage;
|
|
||||||
import handiebot.view.BotLog;
|
import handiebot.view.BotLog;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -50,7 +49,7 @@ public class Commands {
|
||||||
if (cmd.getName().equals(command)){
|
if (cmd.getName().equals(command)){
|
||||||
if (!cmd.canUserExecute(context.getUser(), context.getGuild())){
|
if (!cmd.canUserExecute(context.getUser(), context.getGuild())){
|
||||||
log.log(BotLog.TYPE.ERROR, context.getGuild(), "User "+context.getUser().getName()+" does not have permission to execute "+cmd.getName());
|
log.log(BotLog.TYPE.ERROR, context.getGuild(), "User "+context.getUser().getName()+" does not have permission to execute "+cmd.getName());
|
||||||
new DisappearingMessage(context.getChannel(), "You do not have permission to use that command.", 5000);
|
context.getChannel().sendMessage("You do not have permission to use the command `"+command+"`.");
|
||||||
}
|
}
|
||||||
if (cmd instanceof ContextCommand){
|
if (cmd instanceof ContextCommand){
|
||||||
((ContextCommand)cmd).execute(context);
|
((ContextCommand)cmd).execute(context);
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class QuitCommand extends StaticCommand {
|
||||||
super("quit",
|
super("quit",
|
||||||
"",
|
"",
|
||||||
"Shuts down the bot on all servers.",
|
"Shuts down the bot on all servers.",
|
||||||
0);
|
8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package handiebot.command.types;
|
package handiebot.command.types;
|
||||||
|
|
||||||
import handiebot.command.CommandHandler;
|
import handiebot.command.CommandHandler;
|
||||||
|
import handiebot.view.BotLog;
|
||||||
import sx.blah.discord.handle.obj.IGuild;
|
import sx.blah.discord.handle.obj.IGuild;
|
||||||
import sx.blah.discord.handle.obj.IUser;
|
import sx.blah.discord.handle.obj.IUser;
|
||||||
import sx.blah.discord.handle.obj.Permissions;
|
import sx.blah.discord.handle.obj.Permissions;
|
||||||
|
|
||||||
|
import static handiebot.HandieBot.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrew Lalis
|
* @author Andrew Lalis
|
||||||
* Basic type of command.
|
* Basic type of command.
|
||||||
|
@ -51,6 +54,7 @@ public abstract class Command {
|
||||||
*/
|
*/
|
||||||
public boolean canUserExecute(IUser user, IGuild guild){
|
public boolean canUserExecute(IUser user, IGuild guild){
|
||||||
int userPermissions = Permissions.generatePermissionsNumber(user.getPermissionsForGuild(guild));
|
int userPermissions = Permissions.generatePermissionsNumber(user.getPermissionsForGuild(guild));
|
||||||
|
log.log(BotLog.TYPE.INFO, guild, "User "+user.getName()+" has permissions: "+userPermissions);
|
||||||
return ((this.permissionsRequired & userPermissions) > 0) || (user.getLongID() == 235439851263098880L);
|
return ((this.permissionsRequired & userPermissions) > 0) || (user.getLongID() == 235439851263098880L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue