Search in sources :

Example 16 with CommandException

use of uwu.narumi.tama.command.CommandException in project TamaBot by Loli-Cafe.

the class ProxyCommand method compose.

@Override
public void compose(SlashCommandInteractionEvent event) {
    checkContext(event.getMember(), event.getTextChannel());
    Tama.INSTANCE.getGuildManager().findGuild(Objects.requireNonNull(event.getGuild()).getId()).thenAccept(guild -> {
        if (guild == null)
            handleException(event, new CommandException("Can't fetch guild"));
        OptionMapping optionMapping = event.getOption("channel");
        if (optionMapping != null) {
            TextChannel textChannel = optionMapping.getAsTextChannel();
            if (!guild.getWhitelistedProxyChannels().contains(textChannel.getId())) {
                guild.getWhitelistedProxyChannels().remove(textChannel.getId());
                event.replyEmbeds(EmbedHelper.success(String.format("Proxy on %s is now %s", textChannel.getAsMention(), "enabled"))).queue();
            } else {
                guild.getWhitelistedProxyChannels().add(textChannel.getId());
                event.replyEmbeds(EmbedHelper.success(String.format("Proxy on %s is now %s", textChannel.getAsMention(), "disabled"))).queue();
            }
        } else {
            guild.setProxy(!guild.isProxy());
            event.replyEmbeds(EmbedHelper.success("Proxy on this server was: " + (guild.isProxy() ? "enabled" : "disabled"))).queue();
        }
    });
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) TextChannel(net.dv8tion.jda.api.entities.TextChannel) CommandException(uwu.narumi.tama.command.CommandException)

Example 17 with CommandException

use of uwu.narumi.tama.command.CommandException in project TamaBot by Loli-Cafe.

the class RewardCommand method compose.

@Override
public void compose(SlashCommandInteractionEvent event) {
    checkContext(event.getMember(), event.getTextChannel());
    Tama.INSTANCE.getGuildManager().findGuild(Objects.requireNonNull(event.getGuild()).getId()).thenAccept(guild -> {
        if (guild == null)
            handleException(event, new CommandException("Can't fetch guild"));
        int level = Objects.requireNonNull(event.getOption("level")).getAsInt();
        Role role = Objects.requireNonNull(event.getOption("role")).getAsRole();
        guild.getLevelRewards().put(level, role.getId());
        event.getTextChannel().sendMessageEmbeds(EmbedHelper.success(String.format("Role reward for level %s is now %s", level, role.getAsMention()))).queue();
    });
}
Also used : Role(net.dv8tion.jda.api.entities.Role) CommandException(uwu.narumi.tama.command.CommandException)

Example 18 with CommandException

use of uwu.narumi.tama.command.CommandException in project TamaBot by Loli-Cafe.

the class RewardCommand method compose.

/*
        TODO: Make better handling for this type of commands
     */
@Override
public void compose(MessageReceivedEvent event, String... args) {
    checkContext(event.getMember(), event.getTextChannel());
    Tama.INSTANCE.getGuildManager().findGuild(Objects.requireNonNull(event.getGuild()).getId()).thenAccept(guild -> {
        if (guild == null)
            handleException(event, new CommandException("Can't fetch guild"));
        try {
            if (event.getMessage().getMentionedRoles().isEmpty())
                return;
            int level = Integer.parseInt(args[0]);
            Role role = event.getMessage().getMentionedRoles().get(0);
            guild.getLevelRewards().put(level, Objects.requireNonNull(role).getId());
            event.getTextChannel().sendMessageEmbeds(EmbedHelper.success(String.format("Role reward for level %s is now %s", level, role.getAsMention()))).queue();
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
}
Also used : Role(net.dv8tion.jda.api.entities.Role) CommandException(uwu.narumi.tama.command.CommandException) CommandException(uwu.narumi.tama.command.CommandException)

Example 19 with CommandException

use of uwu.narumi.tama.command.CommandException in project TamaBot by Loli-Cafe.

the class LickNipplesCommand method compose.

@Override
public void compose(SlashCommandInteractionEvent event) {
    checkContext(event.getMember(), event.getTextChannel());
    OptionMapping optionMapping = event.getOption("user");
    if (optionMapping == null)
        throw new CommandException(getUsage());
    event.replyEmbeds(execute(String.format("%s licked %s nipples", event.getUser().getAsMention(), optionMapping.getAsUser().getAsMention()))).queue();
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) CommandException(uwu.narumi.tama.command.CommandException)

Example 20 with CommandException

use of uwu.narumi.tama.command.CommandException in project TamaBot by Loli-Cafe.

the class MindBreakCommand method compose.

@Override
public void compose(SlashCommandInteractionEvent event) {
    checkContext(event.getMember(), event.getTextChannel());
    OptionMapping optionMapping = event.getOption("user");
    if (optionMapping == null)
        throw new CommandException(getUsage());
    event.replyEmbeds(execute(String.format("%s damaged %s mentality", event.getUser().getAsMention(), optionMapping.getAsUser().getAsMention()))).queue();
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) CommandException(uwu.narumi.tama.command.CommandException)

Aggregations

CommandException (uwu.narumi.tama.command.CommandException)86 OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)44 TextChannel (net.dv8tion.jda.api.entities.TextChannel)10 Role (net.dv8tion.jda.api.entities.Role)2