Search in sources :

Example 16 with CommandSubscriber

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

the class Rules method command_setRegeln.

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

Example 17 with CommandSubscriber

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

the class Rules method command_setFooter.

@CommandSubscriber(command = "setFooter", help = "Footer der Begüßungsnachricht ändern.", permissionLevel = PermissionLevel.ADMIN, pmAllowed = false)
public void command_setFooter(final IMessage message, final String footer) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    guildJSON.put("footer", footer);
    saveJSON();
    DiscordIO.sendMessage(message.getChannel(), ":white_check_mark: Begrüßungs-Footer geändert:");
    DiscordIO.sendMessage(message.getChannel(), footer);
    LOG.info(String.format("%s changed rules. (DE)", 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)

Example 18 with CommandSubscriber

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

the class UserLog method command_userlogTest.

@CommandSubscriber(command = "userlogTest", help = "Userlog-Ausgabe testen", permissionLevel = PermissionLevel.ADMIN)
public void command_userlogTest(final IMessage message) {
    final IUser user = message.getAuthor();
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    if (!guildJSON.has("channel")) {
        DiscordIO.sendMessage(message.getChannel(), "Fehler! Kein Kanal hinterlegt!");
        return;
    }
    final long channelID = guildJSON.getLong("channel");
    final IChannel channel = guild.getChannelByID(channelID);
    if (channel != null) {
        userJoinNotify(user, channel);
        userLeaveNotify(user, channel);
        userBanNotify(user, channel);
    }
}
Also used : IChannel(sx.blah.discord.handle.obj.IChannel) JSONObject(org.json.JSONObject) IUser(sx.blah.discord.handle.obj.IUser) IGuild(sx.blah.discord.handle.obj.IGuild) CommandSubscriber(de.nikos410.discordbot.framework.annotations.CommandSubscriber)

Example 19 with CommandSubscriber

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

the class UserLog method command_disableUserlog.

@CommandSubscriber(command = "disableUserlog", help = "Userlog deaktivieren", permissionLevel = PermissionLevel.ADMIN)
public void command_disableUserlog(final IMessage message) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    guildJSON.put("on", false);
    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)

Example 20 with CommandSubscriber

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

the class Rules method command_rules.

@CommandSubscriber(command = "rules", help = "The rules of this server", pmAllowed = false)
public void command_rules(final IMessage message) {
    final IGuild guild = message.getGuild();
    final JSONObject guildJSON = getJSONForGuild(guild);
    if (guildJSON.has("rulesEN")) {
        DiscordIO.sendMessage(message.getAuthor().getOrCreatePMChannel(), guildJSON.getString("rulesEN"));
        if (!message.getChannel().isPrivate()) {
            DiscordIO.sendMessage(message.getChannel(), ":mailbox_with_mail:");
        }
    } else {
        DiscordIO.sendMessage(message.getChannel(), "No rules found for this server.");
    }
}
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