Search in sources :

Example 1 with BAN_MEMBERS

use of net.dv8tion.jda.api.Permission.BAN_MEMBERS in project OrderlyDiscordBot by IceLeiYu.

the class Ban method onCommand.

public void onCommand(SlashCommandInteractionEvent event) {
    if (!permissionCheck(BAN_MEMBERS, event, true))
        return;
    List<String> lang = Main.language.getGuildLang(event.getGuild().getId());
    User user = event.getOption(USER_TAG).getAsUser();
    // Member member = event.getGuild().retrieveMemberById(user.getId()).complete();
    Member selfMember = event.getGuild().getSelfMember();
    if (!selfMember.hasPermission(BAN_MEMBERS)) {
        event.getHook().editOriginalEmbeds(createEmbed(lang.get(BAN_NO_PERMISSION), 0xFF0000)).queue();
        return;
    }
    if (botOwnerID.contains(user.getId())) {
        event.getHook().editOriginalEmbeds(createEmbed(lang.get(BAN_DEVELOPER), 0xFF0000)).queue();
        return;
    }
    // if (event.getGuild().retrieveBanList().complete().contains(user)) {
    int delDays = 0;
    OptionMapping option = event.getOption(DAYS);
    if (option != null)
        delDays = (int) Math.max(0, Math.min(7, option.getAsLong()));
    event.getGuild().ban(user, delDays).flatMap(v -> event.getHook().editOriginalEmbeds(createEmbed(lang.get(BAN_SUCCESS) + ' ' + user.getAsTag(), 0xffb1b3))).queue();
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) USER_TAG(com.ice.main.util.SlashCommandOption.USER_TAG) LangKey(com.ice.main.lang.LangKey) Main(com.ice.main.Main) SlashCommandInteractionEvent(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent) Member(net.dv8tion.jda.api.entities.Member) BotSetting.botOwnerID(com.ice.main.BotSetting.botOwnerID) EmbedCreator.createEmbed(com.ice.main.util.EmbedCreator.createEmbed) User(net.dv8tion.jda.api.entities.User) BAN_MEMBERS(net.dv8tion.jda.api.Permission.BAN_MEMBERS) List(java.util.List) PermissionERROR.permissionCheck(com.ice.main.util.PermissionERROR.permissionCheck) OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) DAYS(com.ice.main.util.SlashCommandOption.DAYS) User(net.dv8tion.jda.api.entities.User) Member(net.dv8tion.jda.api.entities.Member)

Aggregations

BotSetting.botOwnerID (com.ice.main.BotSetting.botOwnerID)1 Main (com.ice.main.Main)1 LangKey (com.ice.main.lang.LangKey)1 EmbedCreator.createEmbed (com.ice.main.util.EmbedCreator.createEmbed)1 PermissionERROR.permissionCheck (com.ice.main.util.PermissionERROR.permissionCheck)1 DAYS (com.ice.main.util.SlashCommandOption.DAYS)1 USER_TAG (com.ice.main.util.SlashCommandOption.USER_TAG)1 List (java.util.List)1 BAN_MEMBERS (net.dv8tion.jda.api.Permission.BAN_MEMBERS)1 Member (net.dv8tion.jda.api.entities.Member)1 User (net.dv8tion.jda.api.entities.User)1 SlashCommandInteractionEvent (net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)1 OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)1