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();
}
}
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();
}
}
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();
}
}
Aggregations