Java Code Examples for net.dv8tion.jda.api.Permission#MANAGE_SERVER

The following examples show how to use net.dv8tion.jda.api.Permission#MANAGE_SERVER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnounceCommand.java    From SkyBot with GNU Affero General Public License v3.0 7 votes vote down vote up
public AnnounceCommand() {
    this.requiresArgs = true;
    this.requiredArgCount = 2;
    this.category = CommandCategory.ADMINISTRATION;
    this.name = "announce";
    this.aliases = new String[]{
        "announce1",
        "announce2",
        "announce3",
    };
    this.help = "Sends an announcement in the specified channel";
    this.usage = "<#channel> <message> [--noembed] [--thumbnail]";
    this.userPermissions = new Permission[]{
        Permission.MANAGE_SERVER,
    };
    this.flags = new Flag[]{
        new Flag(
            "noembed",
            "Displays the announcement as plain text instead of as embed"
        ),
        new Flag(
            "thumbnail",
            "Displays the image as thumbnail instead of a large image"
        ),
    };
}
 
Example 2
Source File: UnmuteCommand.java    From SkyBot with GNU Affero General Public License v3.0 6 votes vote down vote up
public UnmuteCommand() {
    this.shouldLoadMembers = true;
    this.requiresArgs = true;
    this.name = "unmute";
    this.help = "Removes the mute of a user if they are muted";
    this.usage = "<@user> [-r reason]";
    this.botPermissions = new Permission[]{
        Permission.MANAGE_SERVER,
        Permission.MANAGE_ROLES,
    };
    this.flags = new Flag[]{
        new Flag(
            'r',
            "reason",
            "Sets the reason for this umnute"
        ),
    };
}
 
Example 3
Source File: TempMuteCommand.java    From SkyBot with GNU Affero General Public License v3.0 6 votes vote down vote up
public TempMuteCommand() {
    this.shouldLoadMembers = true;
    this.requiresArgs = true;
    this.requiredArgCount = 2;
    this.name = "tempmute";
    this.help = "Temporally mutes a user in the server, this will override any existing tempmutes for the user";
    this.usage = "<@user> <time><w/d/h/m/s> [-r reason]";
    this.botPermissions = new Permission[]{
        Permission.MANAGE_SERVER,
        Permission.MANAGE_ROLES,
    };
    this.flags = new Flag[]{
        new Flag(
            'r',
            "reason",
            "Sets the reason for this mute"
        ),
    };
}
 
Example 4
Source File: MuteCommand.java    From SkyBot with GNU Affero General Public License v3.0 6 votes vote down vote up
public MuteCommand() {
    this.shouldLoadMembers = true;
    this.requiresArgs = true;
    this.name = "mute";
    this.help = "Mutes a user in the server";
    this.usage = "<@user> [-r reason]";
    this.botPermissions = new Permission[]{
        Permission.MANAGE_SERVER,
        Permission.MANAGE_ROLES,
    };
    this.flags = new Flag[]{
        new Flag(
            'r',
            "reason",
            "Sets the reason for this mute"
        ),
    };
}
 
Example 5
Source File: GuildImpl.java    From JDA with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public RestAction<List<Invite>> retrieveInvites()
{
    if (!this.getSelfMember().hasPermission(Permission.MANAGE_SERVER))
        throw new InsufficientPermissionException(this, Permission.MANAGE_SERVER);

    final Route.CompiledRoute route = Route.Invites.GET_GUILD_INVITES.compile(getId());

    return new RestActionImpl<>(getJDA(), route, (response, request) ->
    {
        EntityBuilder entityBuilder = api.getEntityBuilder();
        DataArray array = response.getArray();
        List<Invite> invites = new ArrayList<>(array.length());
        for (int i = 0; i < array.length(); i++)
            invites.add(entityBuilder.createInvite(array.getObject(i)));
        return Collections.unmodifiableList(invites);
    });
}
 
Example 6
Source File: SettingsBase.java    From SkyBot with GNU Affero General Public License v3.0 5 votes vote down vote up
public SettingsBase() {
    this.displayAliasesInHelp = true;
    this.category = CommandCategory.ADMINISTRATION;
    this.userPermissions = new Permission[]{
        Permission.MANAGE_SERVER,
    };
}
 
Example 7
Source File: PurgeChannelCommand.java    From SkyBot with GNU Affero General Public License v3.0 5 votes vote down vote up
public PurgeChannelCommand() {
    this.requiresArgs = true;
    this.name = "purgechannel";
    this.help = "Purges an entire text channel";
    this.usage = "<#channel>";
    this.userPermissions = new Permission[]{
        Permission.MESSAGE_MANAGE,
        Permission.MESSAGE_HISTORY,
    };
    this.botPermissions = new Permission[]{
        Permission.MANAGE_CHANNEL,
        Permission.MANAGE_SERVER,
    };
}
 
Example 8
Source File: GuildManagerImpl.java    From JDA with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkPermissions()
{
    if (!getGuild().getSelfMember().hasPermission(Permission.MANAGE_SERVER))
        throw new InsufficientPermissionException(getGuild(), Permission.MANAGE_SERVER);
    return super.checkPermissions();
}
 
Example 9
Source File: GuildImpl.java    From JDA with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@Deprecated
public RestAction<String> retrieveVanityUrl()
{
    if (!getSelfMember().hasPermission(Permission.MANAGE_SERVER))
        throw new InsufficientPermissionException(this, Permission.MANAGE_SERVER);
    if (!getFeatures().contains("VANITY_URL"))
        throw new IllegalStateException("This guild doesn't have a vanity url");

    Route.CompiledRoute route = Route.Guilds.GET_VANITY_URL.compile(getId());

    return new RestActionImpl<>(getJDA(), route,
        (response, request) -> response.getObject().getString("code"));
}