Search in sources :

Example 1 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.

the class ModStuff method command_Unmute.

@CommandSubscriber(command = "unmute", help = "Nutzer entmuten", pmAllowed = false, permissionLevel = CommandPermissions.MODERATOR)
public void command_Unmute(final IMessage message) {
    final List<IUser> mentions = message.getMentions();
    if (mentions.size() < 1) {
        Util.sendMessage(message.getChannel(), ":x: Fehler: Kein Nutzer angegeben!");
        return;
    } else if (mentions.size() > 1) {
        Util.sendMessage(message.getChannel(), ":x: Fehler: mehrere Nutzer erwähnt");
        return;
    }
    final IUser muteUser = mentions.get(0);
    if (!mutedUsers.containsKey(muteUser.getStringID())) {
        // Nutzer ist nicht gemuted
        Util.sendMessage(message.getChannel(), "Nutzer scheint nicht gemuted zu sein.");
        return;
    }
    ScheduledFuture future = mutedUsers.get(muteUser.getStringID());
    future.cancel(false);
    IRole muteRole = message.getGuild().getRoleByID(muteRoleID);
    muteUser.removeRole(muteRole);
    // :white_check_mark:
    message.addReaction(ReactionEmoji.of("✅"));
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) CommandSubscriber(de.nikos410.discordBot.util.modular.annotations.CommandSubscriber)

Example 2 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.

the class UserLog method command_Userlog_Test.

@CommandSubscriber(command = "userlog_test", help = "Userlog-Ausgabe testen", permissionLevel = CommandPermissions.ADMIN)
public void command_Userlog_Test(final IMessage message) {
    final IUser user = message.getAuthor();
    userJoinNotify(user);
    userLeaveNotify(user);
    userBanNotify(user);
}
Also used : IUser(sx.blah.discord.handle.obj.IUser) CommandSubscriber(de.nikos410.discordBot.util.modular.annotations.CommandSubscriber)

Example 3 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.

the class ModStuff method command_voicelog.

@CommandSubscriber(command = "voicelog", help = "Die letzten 20 Aktivitäten in Sprachkanälen auflisten", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR, ignoreParameterCount = true)
public void command_voicelog(final IMessage message, final String listCountArg) {
    final int listCount;
    if (listCountArg == null) {
        listCount = 20;
    } else {
        try {
            listCount = Integer.parseInt(listCountArg);
        } catch (NumberFormatException e) {
            DiscordIO.sendMessage(message.getChannel(), ":x: Die angegebene Anzahl ist keine gültige Zahl!");
            return;
        }
    }
    final List<String> guildVoiceLog = getVoiceLogForGuild(message.getGuild());
    final StringBuilder stringBuilder = new StringBuilder();
    boolean entriesSkipped = false;
    for (int i = guildVoiceLog.size() - 1; i > (guildVoiceLog.size() - listCount - 1) && i >= 0; i--) {
        final String lineToAdd = guildVoiceLog.get(i);
        if (stringBuilder.length() + lineToAdd.length() <= 1024) {
            stringBuilder.append(guildVoiceLog.get(i));
            stringBuilder.append(String.format("%n"));
        } else {
            entriesSkipped = true;
        }
    }
    final EmbedBuilder responseBuilder = new EmbedBuilder();
    final String content = stringBuilder.length() > 0 ? stringBuilder.toString() : "_keine_";
    responseBuilder.appendField(String.format("__Die letzten %s Voice-Interaktionen (von neu nach alt)__", listCount), content, false);
    if (entriesSkipped) {
        responseBuilder.withFooterText("Einer oder mehrere Einträge wurden ignoriert, weil die maximale Textlänge erreicht wurde.");
    }
    DiscordIO.sendEmbed(message.getChannel(), responseBuilder.build());
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 4 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.

the class ModStuff method command_setModlogChannel.

@CommandSubscriber(command = "setModlogChannel", help = "Kanal in dem die Modlog Nachrichten gesendet werden einstellen", pmAllowed = false, passContext = false, permissionLevel = PermissionLevel.ADMIN)
public void command_setModlogChannel(final IMessage message, final String channelParameter) {
    final IChannel modlogChannel = ChannelUtils.getChannelFromMessage(message, channelParameter);
    if (modlogChannel == null) {
        // No valid channel was specified
        DiscordIO.sendMessage(message.getChannel(), "Kein gültiger Kanal angegeben!");
        return;
    }
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON;
    if (modstuffJSON.has(guild.getStringID())) {
        guildJSON = modstuffJSON.getJSONObject(guild.getStringID());
    } else {
        guildJSON = new JSONObject();
        modstuffJSON.put(guild.getStringID(), guildJSON);
    }
    guildJSON.put("modlogChannel", modlogChannel.getLongID());
    saveJSON();
    // :white_check_mark:
    message.addReaction(ReactionEmoji.of("✅"));
}
Also used : JSONObject(org.json.JSONObject) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 5 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.

the class ModStuff method command_setMuteRole.

@CommandSubscriber(command = "setMuteRole", help = "Mute Rolle einstellen", pmAllowed = false, passContext = false, permissionLevel = PermissionLevel.ADMIN)
public void command_setMuteRole(final IMessage message, final String roleParameter) {
    final IRole muteRole = GuildUtils.getRoleFromMessage(message, roleParameter);
    if (muteRole == null) {
        // No valid role specified
        DiscordIO.sendMessage(message.getChannel(), "Keine gültige Rolle angegeben!");
        return;
    }
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON;
    if (modstuffJSON.has(guild.getStringID())) {
        guildJSON = modstuffJSON.getJSONObject(guild.getStringID());
    } else {
        guildJSON = new JSONObject();
        modstuffJSON.put(guild.getStringID(), guildJSON);
    }
    guildJSON.put("muteRole", muteRole.getLongID());
    saveJSON();
    // :white_check_mark:
    message.addReaction(ReactionEmoji.of("✅"));
}
Also used : JSONObject(org.json.JSONObject) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Aggregations

CommandSubscriber (de.nikos410.discordbot.framework.annotations.CommandSubscriber)19 JSONObject (org.json.JSONObject)17 IGuild (sx.blah.discord.handle.obj.IGuild)11 CommandSubscriber (de.nikos410.discordBot.util.modular.annotations.CommandSubscriber)4 ChronoUnit (java.time.temporal.ChronoUnit)4 CommandWrapper (de.nikos410.discordbot.framework.CommandWrapper)2 PermissionLevel (de.nikos410.discordbot.framework.PermissionLevel)2 CommandUtils (de.nikos410.discordbot.util.CommandUtils)2 Method (java.lang.reflect.Method)2 ScheduledFuture (java.util.concurrent.ScheduledFuture)2 IChannel (sx.blah.discord.handle.obj.IChannel)2 IUser (sx.blah.discord.handle.obj.IUser)2 CommandModule (de.nikos410.discordBot.util.modular.annotations.CommandModule)1 InitializationException (de.nikos410.discordbot.exception.InitializationException)1 CommandModule (de.nikos410.discordbot.framework.CommandModule)1 ModuleWrapper (de.nikos410.discordbot.framework.ModuleWrapper)1 ModuleStatus (de.nikos410.discordbot.framework.ModuleWrapper.ModuleStatus)1 BotSetup (de.nikos410.discordbot.modules.BotSetup)1 Authorization (de.nikos410.discordbot.util.discord.Authorization)1 DiscordIO (de.nikos410.discordbot.util.discord.DiscordIO)1