Search in sources :

Example 11 with Member

use of net.dv8tion.jda.core.entities.Member in project Rubicon by Rubicon-Bot.

the class CommandWhitelist method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    String[] args = parsedCommandInvocation.getArgs();
    Member member = parsedCommandInvocation.getMember();
    Guild guild = parsedCommandInvocation.getGuild();
    TextChannel channel = parsedCommandInvocation.getTextChannel();
    Message message = parsedCommandInvocation.getMessage();
    if (args.length == 0)
        return createHelpMessage();
    GuildSQL guildSQL = GuildSQL.fromGuild(guild);
    if (guildSQL.enabledBlacklist()) {
        return new MessageBuilder().setEmbed(EmbedUtil.error("Already using blacklist", "You can't use black- and whitelist on the same server").build()).build();
    }
    switch(args[0]) {
        case "list":
            executeList(args, member, guild, channel);
            break;
        case "add":
        case "whitelist":
            executeAdd(args, member, guild, channel, message);
            break;
        case "remove":
        case "blacklist":
            executeRemove(args, member, guild, channel, message);
            break;
        default:
            SafeMessage.sendMessage(channel, createHelpMessage(), 5);
            break;
    }
    return null;
}
Also used : GuildSQL(fun.rubicon.sql.GuildSQL) TextChannel(net.dv8tion.jda.core.entities.TextChannel) SafeMessage(fun.rubicon.util.SafeMessage) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Guild(net.dv8tion.jda.core.entities.Guild) Member(net.dv8tion.jda.core.entities.Member)

Example 12 with Member

use of net.dv8tion.jda.core.entities.Member in project Rubicon by Rubicon-Bot.

the class CommandRole method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Message message = parsedCommandInvocation.getMessage();
    String[] args = parsedCommandInvocation.getArgs();
    if (args.length < 2 || message.getMentionedUsers().isEmpty())
        return createHelpMessage();
    GuildController controller = message.getGuild().getController();
    Member member = message.getGuild().getMember(message.getMentionedUsers().get(0));
    // Get Role
    int userNameArgsLength = message.getMentionedUsers().get(0).getAsMention().split(" ").length;
    String rolename = args[userNameArgsLength + 1];
    if (member.getGuild().getRolesByName(rolename, true).isEmpty())
        return new MessageBuilder().setEmbed(EmbedUtil.error("Unknown role", "That role doesn't exist").build()).build();
    Role role = member.getGuild().getRolesByName(rolename, true).get(0);
    Member issuer = message.getMember();
    if (!issuer.canInteract(role))
        return new MessageBuilder().setEmbed(EmbedUtil.error("Not permitted", "You are not permitted to assign or remove that role").build()).build();
    if (!message.getGuild().getSelfMember().canInteract(role))
        return new MessageBuilder().setEmbed(EmbedUtil.error("Not permitted", "I'm not permitted to assign or remove that role").build()).build();
    if (args[0].equals("add")) {
        controller.addRolesToMember(member, role).queue();
        return new MessageBuilder().setEmbed(EmbedUtil.success("Assigned role", "Successfully asigned role `" + role.getName() + "` to " + member.getAsMention()).build()).build();
    } else if (args[0].equals("remove")) {
        controller.removeRolesFromMember(member, role).queue();
        return new MessageBuilder().setEmbed(EmbedUtil.success("Removed role", "Successfully removed role `" + role.getName() + "` from " + member.getAsMention()).build()).build();
    } else
        return createHelpMessage();
}
Also used : Role(net.dv8tion.jda.core.entities.Role) GuildController(net.dv8tion.jda.core.managers.GuildController) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Member(net.dv8tion.jda.core.entities.Member)

Example 13 with Member

use of net.dv8tion.jda.core.entities.Member in project Rubicon by Rubicon-Bot.

the class CommandUnmute method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Message message = parsedCommandInvocation.getMessage();
    Member user = parsedCommandInvocation.getMember();
    Guild guild = parsedCommandInvocation.getGuild();
    if (message.getMentionedUsers().isEmpty())
        return createHelpMessage();
    Member victim = guild.getMember(message.getMentionedUsers().get(0));
    if (!user.canInteract(victim))
        return new MessageBuilder().setEmbed(EmbedUtil.error("No permission", "You have no permission to interact with " + victim.getAsMention()).build()).build();
    Role muted = CommandMute.createMutedRoleIfNotExists(guild, null);
    if (!victim.getRoles().contains(muted))
        return new MessageBuilder().setEmbed(EmbedUtil.error("Not muted", "This user is not muted").build()).build();
    guild.getController().removeSingleRoleFromMember(victim, muted).queue();
    return new MessageBuilder().setEmbed(EmbedUtil.success("Unmuted", "Successfully unmuted " + victim.getAsMention()).build()).build();
}
Also used : Role(net.dv8tion.jda.core.entities.Role) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Guild(net.dv8tion.jda.core.entities.Guild) Member(net.dv8tion.jda.core.entities.Member)

Example 14 with Member

use of net.dv8tion.jda.core.entities.Member in project Rubicon by Rubicon-Bot.

the class CommandUserInfo method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Message message = parsedCommandInvocation.getMessage();
    User info;
    String[] args = parsedCommandInvocation.getArgs();
    if (args.length > 0) {
        if (message.getMentionedUsers().size() > 0)
            info = message.getMentionedUsers().get(0);
        else {
            return createHelpMessage();
        }
    } else {
        info = message.getAuthor();
    }
    Member user = message.getGuild().getMember(info);
    StringBuilder rawRoles = new StringBuilder();
    user.getRoles().forEach(r -> rawRoles.append(r.getName()).append(", "));
    StringBuilder roles = new StringBuilder(rawRoles.toString());
    if (!user.getRoles().isEmpty())
        roles.replace(rawRoles.lastIndexOf(","), roles.lastIndexOf(",") + 1, "");
    EmbedBuilder userinfo = new EmbedBuilder();
    userinfo.setColor(Colors.COLOR_PRIMARY);
    userinfo.setTitle("User information of " + user.getUser().getName());
    userinfo.setThumbnail(info.getAvatarUrl());
    userinfo.addField("Nickname", user.getEffectiveName(), false);
    userinfo.addField("User id", info.getId(), false);
    userinfo.addField("Status", user.getOnlineStatus().toString().replace("_", ""), false);
    if (user.getGame() != null)
        userinfo.addField("Game", user.getGame().getName(), false);
    userinfo.addField("Guild join date", formatDate(user.getJoinDate()), false);
    userinfo.addField("Roles", "`" + roles.toString() + "`", false);
    userinfo.addField("Discord join date", formatDate(info.getCreationTime()), false);
    userinfo.addField("Avatar url", (info.getAvatarUrl() != null) ? info.getAvatarUrl() : "https://rubicon.fun", true);
    return new MessageBuilder().setEmbed(userinfo.build()).build();
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) User(net.dv8tion.jda.core.entities.User) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Member(net.dv8tion.jda.core.entities.Member)

Example 15 with Member

use of net.dv8tion.jda.core.entities.Member in project Rubicon by Rubicon-Bot.

the class CommandBlacklist method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    String[] args = parsedCommandInvocation.getArgs();
    Member member = parsedCommandInvocation.getMember();
    Guild guild = parsedCommandInvocation.getGuild();
    TextChannel channel = parsedCommandInvocation.getTextChannel();
    Message message = parsedCommandInvocation.getMessage();
    if (args.length == 0)
        return createHelpMessage();
    GuildSQL guildSQL = GuildSQL.fromGuild(guild);
    if (guildSQL.enabledWhitelist()) {
        return new MessageBuilder().setEmbed(EmbedUtil.error("Already using whitelist", "You can't use black- and whitelist on the same server").build()).build();
    }
    switch(args[0]) {
        case "list":
            executeList(args, member, guild, channel);
            break;
        case "add":
        case "blacklist":
            executeAdd(args, member, guild, channel, message);
            break;
        case "remove":
        case "whitelist":
            executeRemove(args, member, guild, channel, message);
            break;
        default:
            SafeMessage.sendMessage(channel, createHelpMessage(), 5);
            break;
    }
    return null;
}
Also used : GuildSQL(fun.rubicon.sql.GuildSQL) TextChannel(net.dv8tion.jda.core.entities.TextChannel) SafeMessage(fun.rubicon.util.SafeMessage) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Guild(net.dv8tion.jda.core.entities.Guild) Member(net.dv8tion.jda.core.entities.Member)

Aggregations

Member (net.dv8tion.jda.core.entities.Member)69 Message (net.dv8tion.jda.core.entities.Message)23 Guild (net.dv8tion.jda.core.entities.Guild)22 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)19 User (net.dv8tion.jda.core.entities.User)19 TextChannel (net.dv8tion.jda.core.entities.TextChannel)18 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 GuildWrapper (stream.flarebot.flarebot.objects.GuildWrapper)10 Permission (net.dv8tion.jda.core.Permission)9 MessageUtils (stream.flarebot.flarebot.util.MessageUtils)9 Role (net.dv8tion.jda.core.entities.Role)8 CommandType (stream.flarebot.flarebot.commands.CommandType)8 Collectors (java.util.stream.Collectors)7 FlareBot (stream.flarebot.flarebot.FlareBot)6 Permission (stream.flarebot.flarebot.permissions.Permission)6 Track (com.arsenarsen.lavaplayerbridge.player.Track)5 GuildPlayer (fredboat.audio.player.GuildPlayer)5 AudioTrackContext (fredboat.audio.queue.AudioTrackContext)5