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