Search in sources :

Example 36 with CommandSubscriber

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

the class UserGroups method command_removeGroup.

@CommandSubscriber(command = "removeGroup", help = "Gruppe entfernen", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR)
public void command_removeGroup(final IMessage message, final String groupName) {
    final IGuild guild = message.getGuild();
    // Validate group first
    validateGroup(guild, groupName);
    final JSONObject guildJSON = getJSONForGuild(guild);
    if (!guildJSON.has(groupName)) {
        DiscordIO.sendMessage(message.getChannel(), String.format(":x: Gruppe `%s` nicht gefunden!", groupName));
        return;
    }
    final IRole role = guild.getRoleByID(guildJSON.getLong(groupName));
    role.delete();
    guildJSON.remove(groupName);
    saveJSON();
    DiscordIO.sendMessage(message.getChannel(), String.format(":white_check_mark: Gruppe `%s` entfernt.", groupName));
    LOG.info(String.format("%s deleted group %s.", UserUtils.makeUserString(message.getAuthor(), guild), groupName));
}
Also used : JSONObject(org.json.JSONObject) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 37 with CommandSubscriber

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

the class Rules method command_enableWelcome.

@CommandSubscriber(command = "enableWelcome", help = "Begrüßungsnachricht aktivieren", permissionLevel = PermissionLevel.ADMIN, pmAllowed = false)
public void command_enableWelcome(final IMessage message) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    guildJSON.put("on", true);
    saveJSON();
    DiscordIO.sendMessage(message.getChannel(), ":white_check_mark: Aktiviert!");
    LOG.info(String.format("%s enabled welcome messages for server %s (ID: %s)", UserUtils.makeUserString(message.getAuthor(), message.getGuild()), guild.getName(), guild.getStringID()));
}
Also used : JSONObject(org.json.JSONObject) IGuild(sx.blah.discord.handle.obj.IGuild) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 38 with CommandSubscriber

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

the class Rules method command_disableWelcome.

@CommandSubscriber(command = "disableWelcome", help = "Begrüßungsnachricht deaktivieren", permissionLevel = PermissionLevel.ADMIN, pmAllowed = false)
public void command_disableWelcome(final IMessage message) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    guildJSON.put("on", false);
    saveJSON();
    DiscordIO.sendMessage(message.getChannel(), ":white_check_mark: Deaktiviert!");
    LOG.info(String.format("%s disabled welcome messages for server %s (ID: %s)", UserUtils.makeUserString(message.getAuthor(), message.getGuild()), guild.getName(), guild.getStringID()));
}
Also used : JSONObject(org.json.JSONObject) IGuild(sx.blah.discord.handle.obj.IGuild) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 39 with CommandSubscriber

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

the class Rules method command_regeln.

@CommandSubscriber(command = "regeln", help = "Die Regeln dieses Servers", pmAllowed = false)
public void command_regeln(final IMessage message) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    if (guildJSON.has("rulesDE")) {
        DiscordIO.sendMessage(message.getAuthor().getOrCreatePMChannel(), guildJSON.getString("rulesDE"));
        if (!message.getChannel().isPrivate()) {
            DiscordIO.sendMessage(message.getChannel(), ":mailbox_with_mail:");
        }
    } else {
        DiscordIO.sendMessage(message.getChannel(), "Keine Regeln für diesen Server hinterlegt.");
    }
}
Also used : JSONObject(org.json.JSONObject) IGuild(sx.blah.discord.handle.obj.IGuild) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 40 with CommandSubscriber

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

the class Rules method command_setRules.

@CommandSubscriber(command = "setRules", help = "Regeln (englisch) ändern", permissionLevel = PermissionLevel.ADMIN, pmAllowed = false)
public void command_setRules(final IMessage message, final String rulesEN) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    guildJSON.put("rulesEN", rulesEN);
    saveJSON();
    DiscordIO.sendMessage(message.getChannel(), ":white_check_mark: Regeln (EN) geändert:");
    DiscordIO.sendMessage(message.getChannel(), rulesEN);
    LOG.info(String.format("%s changed rules. (EN)", UserUtils.makeUserString(message.getAuthor(), message.getGuild())));
}
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