Search in sources :

Example 41 with CommandSubscriber

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

the class UserLog method command_setUserlogChannel.

@CommandSubscriber(command = "setUserlogChannel", help = "Kanal für Userlog ändern", permissionLevel = PermissionLevel.ADMIN)
public void command_setUserlogChannel(final IMessage message, final String channel) {
    final IChannel modlogChannel;
    final List<IChannel> channelMentions = message.getChannelMentions();
    if (GuildUtils.channelExists(message.getGuild(), channel)) {
        // Kanal ID wurde als Parameter angegeben
        modlogChannel = message.getGuild().getChannelByID(Long.parseLong(channel));
    } else if (channelMentions.size() == 1) {
        // ein Kanal wurde erwähnt
        modlogChannel = channelMentions.get(0);
    } else {
        // Kein Kanal angegeben
        DiscordIO.sendMessage(message.getChannel(), "Kein gültiger Kanal angegeben!");
        return;
    }
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    guildJSON.put("channel", modlogChannel.getLongID());
    saveUserLogJSON();
    // :white_check_mark:
    message.addReaction(ReactionEmoji.of("✅"));
}
Also used : IChannel(sx.blah.discord.handle.obj.IChannel) JSONObject(org.json.JSONObject) IGuild(sx.blah.discord.handle.obj.IGuild) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 42 with CommandSubscriber

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

the class UserLog method command_enableUserlog.

@CommandSubscriber(command = "enableUserlog", help = "Userlog aktivieren", permissionLevel = PermissionLevel.ADMIN)
public void command_enableUserlog(final IMessage message) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    if (!guildJSON.has("channel")) {
        DiscordIO.sendMessage(message.getChannel(), "Es ist noch kein Kanal hinterlegt!");
    }
    guildJSON.put("on", true);
    saveUserLogJSON();
    // :white_check_mark:
    message.addReaction(ReactionEmoji.of("✅"));
}
Also used : JSONObject(org.json.JSONObject) IGuild(sx.blah.discord.handle.obj.IGuild) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Aggregations

CommandSubscriber (de.nikos410.discordbot.framework.annotations.CommandSubscriber)30 JSONObject (org.json.JSONObject)23 IGuild (sx.blah.discord.handle.obj.IGuild)14 CommandSubscriber (de.nikos410.discordBot.util.modular.annotations.CommandSubscriber)12 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)11 ChronoUnit (java.time.temporal.ChronoUnit)5 EmbedObject (sx.blah.discord.api.internal.json.objects.EmbedObject)5 LocalDateTime (java.time.LocalDateTime)4 DateTimeFormatter (java.time.format.DateTimeFormatter)4 IChannel (sx.blah.discord.handle.obj.IChannel)4 ModuleWrapper (de.nikos410.discordbot.framework.ModuleWrapper)3 CommandUtils (de.nikos410.discordbot.util.CommandUtils)3 Method (java.lang.reflect.Method)3 ScheduledFuture (java.util.concurrent.ScheduledFuture)3 JSONArray (org.json.JSONArray)3 IUser (sx.blah.discord.handle.obj.IUser)3 CommandModule (de.nikos410.discordBot.util.modular.annotations.CommandModule)2 CommandWrapper (de.nikos410.discordbot.framework.CommandWrapper)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2