<commit_before>package com.blamejared.mcbot.commands;

import java.util.Collections;

import com.blamejared.mcbot.commands.api.Argument;
import com.blamejared.mcbot.commands.api.Command;
import com.blamejared.mcbot.commands.api.CommandBase;
import com.blamejared.mcbot.commands.api.CommandContext;
import com.blamejared.mcbot.commands.api.CommandException;
import com.blamejared.mcbot.commands.api.CommandRegistrar;
import com.blamejared.mcbot.commands.api.Flag;
import com.blamejared.mcbot.commands.api.ICommand;
import com.blamejared.mcbot.listeners.CommandListener;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;

import sx.blah.discord.util.EmbedBuilder;

@Command
public class CommandHelp extends CommandBase {
    
    private static final Argument<String> ARG_COMMAND = new WordArgument("command", "The command to get help on.", false);

    public CommandHelp() {
        super("help", false, Collections.emptyList(), Lists.newArrayList(ARG_COMMAND));
    }

    @Override
    public void process(CommandContext ctx) throws CommandException {
        String cmdstr = ctx.getArg(ARG_COMMAND);
        if (cmdstr == null) {
            ctx.reply("To get help on a command, use `" + CommandListener.PREFIX + "help <command>`. To see a list of commands, use `" + CommandListener.PREFIX + "commands`.");
        }
        ICommand command = CommandRegistrar.INSTANCE.findCommand(ctx.getArg(ARG_COMMAND));
        if (command == null) {
            ctx.reply("`" + CommandListener.PREFIX + cmdstr + "` is not a valid command!");
        } else {
            EmbedBuilder embed = new EmbedBuilder();
            embed.withTitle("**Help for " + CommandListener.PREFIX + command.getName() + "**");
            embed.withDesc(Strings.repeat("\u203e", 60));
            embed.appendField("Description:", command.getDescription(), false);
            
            StringBuilder usage = new StringBuilder();
            usage.append('`').append(CommandListener.PREFIX).append(command.getName()).append(' ');
            for (Argument<?> arg : command.getArguments()) {
                if (arg.required(Collections.emptyList())) {<commit_msg>Fix NPE when running !help with no arg<commit_after>package com.blamejared.mcbot.commands;

import java.util.Collections;

import com.blamejared.mcbot.commands.api.Argument;
import com.blamejared.mcbot.commands.api.Command;
import com.blamejared.mcbot.commands.api.CommandBase;
import com.blamejared.mcbot.commands.api.CommandContext;
import com.blamejared.mcbot.commands.api.CommandException;
import com.blamejared.mcbot.commands.api.CommandRegistrar;
import com.blamejared.mcbot.commands.api.Flag;
import com.blamejared.mcbot.commands.api.ICommand;
import com.blamejared.mcbot.listeners.CommandListener;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;

import sx.blah.discord.util.EmbedBuilder;

@Command
public class CommandHelp extends CommandBase {
    
    private static final Argument<String> ARG_COMMAND = new WordArgument("command", "The command to get help on.", false);

    public CommandHelp() {
        super("help", false, Collections.emptyList(), Lists.newArrayList(ARG_COMMAND));
    }

    @Override
    public void process(CommandContext ctx) throws CommandException {
        String cmdstr = ctx.getArg(ARG_COMMAND);
        if (cmdstr == null) {
            ctx.reply("To get help on a command, use `" + CommandListener.PREFIX + "help <command>`. To see a list of commands, use `" + CommandListener.PREFIX + "commands`.");
            return;
        }
        ICommand command = CommandRegistrar.INSTANCE.findCommand(ctx.getArg(ARG_COMMAND));
        if (command == null) {
            ctx.reply("`" + CommandListener.PREFIX + cmdstr + "` is not a valid command!");
        } else {
            EmbedBuilder embed = new EmbedBuilder();
            embed.withTitle("**Help for " + CommandListener.PREFIX + command.getName() + "**");
            embed.withDesc(Strings.repeat("\u203e", 60));
            embed.appendField("Description:", command.getDescription(), false);
            
            StringBuilder usage = new StringBuilder();
            usage.append('`').append(CommandListener.PREFIX).append(command.getName()).append(' ');
            for (Argument<?> arg : command.getArguments()) {
                if (arg.required(Collections.emptyList())) {
{'fraction_non_alphanumeric': 0.12554211367267748, 'fraction_numerical': 0.0022825838849577723, 'mean_word_length': 3.512873326467559, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7148931', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1267, 'n_words': 258}