Search in sources :

Example 1 with PrivateChannel

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

the class CommandBan method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Message msg = parsedCommandInvocation.getMessage();
    if (msg.getMentionedUsers().isEmpty()) {
        return new MessageBuilder().setEmbed(EmbedUtil.info("Usage", "ban <@User>").build()).build();
    }
    Member target = msg.getGuild().getMember(msg.getMentionedUsers().get(0));
    if (!msg.getGuild().getSelfMember().canInteract(target)) {
        return new MessageBuilder().setEmbed(EmbedUtil.error("No permissions", "Sorry I can't ban this User.").build()).build();
    } else {
        if (!target.getUser().isBot()) {
            PrivateChannel channel = target.getUser().openPrivateChannel().complete();
            channel.sendMessage(EmbedUtil.success("Banned", "You got banned").build()).queue();
        }
        msg.getGuild().getController().ban(target, 7).queue();
        return new MessageBuilder().setEmbed(EmbedUtil.success("Banned", "Successfully banned " + target.getAsMention()).build()).build();
    }
}
Also used : PrivateChannel(net.dv8tion.jda.core.entities.PrivateChannel) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Member(net.dv8tion.jda.core.entities.Member)

Example 2 with PrivateChannel

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

the class CommandKick method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    Message msg = parsedCommandInvocation.getMessage();
    if (msg.getMentionedUsers().isEmpty()) {
        return createHelpMessage();
    }
    Member target = msg.getGuild().getMember(msg.getMentionedUsers().get(0));
    if (!msg.getGuild().getSelfMember().canInteract(target)) {
        return new MessageBuilder().setEmbed(EmbedUtil.error("No permissions", "I can't kick this user because his role is higher then my role.").build()).build();
    } else {
        if (!target.getUser().isBot()) {
            PrivateChannel channel = target.getUser().openPrivateChannel().complete();
            channel.sendMessage(EmbedUtil.success("Kicked", "You got kicked").build()).queue();
        }
        msg.getGuild().getController().kick(target).queue();
        return new MessageBuilder().setEmbed(EmbedUtil.success("Kicked", "Succesfully kicked " + target.getAsMention()).build()).build();
    }
}
Also used : PrivateChannel(net.dv8tion.jda.core.entities.PrivateChannel) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Member(net.dv8tion.jda.core.entities.Member)

Example 3 with PrivateChannel

use of net.dv8tion.jda.core.entities.PrivateChannel in project legendarybot by greatman.

the class DebugGuildCommand method execute.

@Override
public void execute(MessageReceivedEvent event, String[] args) {
    if (args.length == 2) {
        List<Guild> userGuilds = new ArrayList<>();
        getBot().getJDA().forEach((jda) -> userGuilds.addAll(jda.getUserById(args[1]).getMutualGuilds()));
        StringBuilder builder = new StringBuilder();
        userGuilds.forEach(guild -> {
            builder.append(guild.getName() + ":" + guild.getId());
        });
        event.getAuthor().openPrivateChannel().queue(new Consumer<PrivateChannel>() {

            @Override
            public void accept(PrivateChannel privateChannel) {
                privateChannel.sendMessage(builder.toString()).queue();
            }
        });
        return;
    }
    final Guild[] guildEntry = { null };
    getBot().getJDA().forEach((jda -> {
        if (guildEntry[0] == null) {
            guildEntry[0] = jda.getGuildById(args[0]);
        }
    }));
    if (guildEntry[0] != null) {
        Guild guild = guildEntry[0];
        StringBuilder builder = new StringBuilder();
        PrivateChannel channel = event.getAuthor().openPrivateChannel().complete();
        builder.append("Guild " + guild.getName() + "\n");
        builder.append("Roles:\n");
        guild.getRoles().forEach((role -> builder.append(role.getName() + "\n")));
        builder.append("Config:\n");
        builder.append("Guild Name: " + getBot().getGuildSettings(guild).getGuildName() + "\n");
        builder.append("Region Name: " + getBot().getGuildSettings(guild).getRegionName() + "\n");
        builder.append("Realm name: " + getBot().getGuildSettings(guild).getWowServerName() + "\n");
        builder.append("WoW Rank config:\n");
        builder.append("Rank 0: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_0") + "\n");
        builder.append("Rank 1: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_1") + "\n");
        builder.append("Rank 2: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_2") + "\n");
        builder.append("Rank 3: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_3") + "\n");
        builder.append("Rank 4: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_4") + "\n");
        builder.append("Rank 5: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_5") + "\n");
        builder.append("Rank 6: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_6") + "\n");
        builder.append("Rank 7: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_7") + "\n");
        builder.append("Rank 8: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_8") + "\n");
        builder.append("Rank 9: " + getBot().getGuildSettings(guild).getSetting("wowlink_rank_9") + "\n");
        builder.append("Rank Enabled: " + getBot().getGuildSettings(guild).getSetting("wowlink_rankset") + "\n");
        channel.sendMessage(builder.toString()).queue();
    }
}
Also used : PrivateChannel(net.dv8tion.jda.core.entities.PrivateChannel) Consumer(java.util.function.Consumer) Guild(net.dv8tion.jda.core.entities.Guild) List(java.util.List) LegendaryBotPlugin(com.greatmancode.legendarybot.api.plugin.LegendaryBotPlugin) Member(net.dv8tion.jda.core.entities.Member) MessageReceivedEvent(net.dv8tion.jda.core.events.message.MessageReceivedEvent) PrivateChannel(net.dv8tion.jda.core.entities.PrivateChannel) Command(com.greatmancode.legendarybot.api.commands.Command) PluginWrapper(org.pf4j.PluginWrapper) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Guild(net.dv8tion.jda.core.entities.Guild)

Aggregations

Member (net.dv8tion.jda.core.entities.Member)3 PrivateChannel (net.dv8tion.jda.core.entities.PrivateChannel)3 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)2 Message (net.dv8tion.jda.core.entities.Message)2 Command (com.greatmancode.legendarybot.api.commands.Command)1 LegendaryBotPlugin (com.greatmancode.legendarybot.api.plugin.LegendaryBotPlugin)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Guild (net.dv8tion.jda.core.entities.Guild)1 MessageReceivedEvent (net.dv8tion.jda.core.events.message.MessageReceivedEvent)1 PluginWrapper (org.pf4j.PluginWrapper)1