|
|
|
@ -67,12 +67,12 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gives the UID of the User passed as arguments
|
|
|
|
|
* Gives the UID of the user passed as arguments
|
|
|
|
|
* @param name The current name of the user
|
|
|
|
|
* @param discriminator His discriminator
|
|
|
|
|
* @return The ID of the target user
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Returns the Unique Identifier of the target user.", permission = DefaultPermission.ANY_OWNER)
|
|
|
|
|
public String getUID(MessageReceivedEvent event, String name, String discriminator)
|
|
|
|
|
{
|
|
|
|
|
for(IUser i : event.getMessage().getGuild().getUsers())
|
|
|
|
@ -85,7 +85,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* Gets caller's UID
|
|
|
|
|
* @return Caller's UID
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Returns your own Unique Identifier")
|
|
|
|
|
public String getMyUID(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
return event.getMessage().getAuthor().getID();
|
|
|
|
@ -96,7 +96,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* @param name The role current name
|
|
|
|
|
* @return The GID of the role
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Returns the Unique Identifier of the targer role.", permission = DefaultPermission.ANY_OWNER)
|
|
|
|
|
public String getGID(MessageReceivedEvent event, String name)
|
|
|
|
|
{
|
|
|
|
|
for(IRole i : event.getMessage().getGuild().getRoles())
|
|
|
|
@ -110,7 +110,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* Note: this commands answers the dump via PM to avoid spam and the @everyone role to be publicly displayed thus notify everyone in the guild.
|
|
|
|
|
* @return The whole dump, formatted as a displayable String
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Gives ALL roles and GID, for debugging purposes.", permission = DefaultPermission.BOT_OWNER)
|
|
|
|
|
public String dumpGID(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
StringBuffer buffer = new StringBuffer("Dumping Roles for Guild ").append(event.getMessage().getGuild().getName()).append("\n");
|
|
|
|
@ -135,7 +135,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* Note: this commands answers the dump via PM to avoid spam.
|
|
|
|
|
* @return The whole dump, formatted as a displayable String
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Gives ALL users and UID, for debugging purposes.", permission = DefaultPermission.BOT_OWNER)
|
|
|
|
|
public String dumpUID(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
StringBuffer buffer = new StringBuffer("Dumping all users for Guild ").append(event.getMessage().getGuild().getName()).append("\n");
|
|
|
|
@ -159,7 +159,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* Reload permissions from file
|
|
|
|
|
* @return Nothing
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Reloads the perm file, discarding all unsaved changes.", permission = DefaultPermission.BOT_OWNER)
|
|
|
|
|
public String reload(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
reloadPermissions();
|
|
|
|
@ -170,7 +170,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* Save permissions to file
|
|
|
|
|
* @return Nothing
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Saves the perm files.", permission = DefaultPermission.ANY_OWNER)
|
|
|
|
|
public String save(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
writePermissions();
|
|
|
|
@ -184,7 +184,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* @param target `true` to allow execution of the command, `false` to deny it, `null` to remove the rule
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Sets an user permission.", permission = DefaultPermission.ANY_OWNER, required = {true, true, false})
|
|
|
|
|
public String setUser(MessageReceivedEvent event, String command, String user, Boolean target)
|
|
|
|
|
{
|
|
|
|
|
if(!permissions.containsKey(event.getMessage().getGuild().getID()))
|
|
|
|
@ -208,7 +208,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* @param target `true` to allow execution of the command, `false` to deny it, `null` to remove the rule
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Sets a role permission.", permission = DefaultPermission.ANY_OWNER, required = {true, true, false})
|
|
|
|
|
public String setRole(MessageReceivedEvent event, String command, String group, Boolean target)
|
|
|
|
|
{
|
|
|
|
|
if(!permissions.containsKey(event.getMessage().getGuild().getID()))
|
|
|
|
@ -229,7 +229,7 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* Dump all permissions defined for the current guild
|
|
|
|
|
* @return Displayable String of the permissions
|
|
|
|
|
*/
|
|
|
|
|
@Command(shorthand = "dumpPerm")
|
|
|
|
|
@Command(description = "Dump all permission for this Guild.", permission = DefaultPermission.ANY_OWNER)
|
|
|
|
|
public String dumpPermissions(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
StringBuffer buffer = new StringBuffer("Dumping all permissions for Guild ").append(event.getMessage().getGuild().getName()).append("\n\n```");
|
|
|
|
@ -268,9 +268,9 @@ class PermissionsModule extends AbstractModule
|
|
|
|
|
* @param user User name
|
|
|
|
|
* @param discriminator His discriminator
|
|
|
|
|
* @param command The target command
|
|
|
|
|
* @return `YES` if he can run it, `NO` if he can't, `N/A` if the decision relies to the default behavior
|
|
|
|
|
* @return `YES` if he can run it, `NO` if he can't, `N/A` if the decision relies on the default behavior
|
|
|
|
|
*/
|
|
|
|
|
@Command
|
|
|
|
|
@Command(description = "Says if the target user can run said command. Ignores default behavior.", permission = DefaultPermission.ANY_OWNER)
|
|
|
|
|
public String canRun(MessageReceivedEvent event, String user, String discriminator, String command)
|
|
|
|
|
{
|
|
|
|
|
IUser target = null;
|
|
|
|
|