Search in sources :

Example 21 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel 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 22 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel 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)

Example 23 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel 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 24 with PermissionLevel

use of de.nikos410.discordbot.framework.PermissionLevel 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)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