package stream.flarebot.flarebot.commands.administrator;

import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
import stream.flarebot.flarebot.MessageUtils;
import stream.flarebot.flarebot.commands.Command;
import stream.flarebot.flarebot.commands.CommandType;

public class PinCommand implements Command {

    @Override
    public void onCommand(User sender, TextChannel channel, Message message, String[] args, Member member) {
        if (args.length == 1 && !args[0].replaceAll("[^0-9]", "").isEmpty()) {
            String messageId = args[0].replaceAll("[^0-9]", "");
            Message msg = channel.getMessageById(messageId).complete();
            msg.pin().complete();
            channel.getHistory().retrievePast(1).complete().get(0).delete().queue();
        } else if (args.length != 0){
            String pinMessage = MessageUtils.getMessage(args, 0);
            Message msg = channel.sendMessage(new EmbedBuilder().setTitle(sender.getName(), null)
                    .setThumbnail(MessageUtils.getAvatar(sender)).setDescription(pinMessage).build()).complete();
            msg.pin().complete();
            channel.getHistory().retrievePast(1).complete().get(0).delete().queue();
        } else {
            MessageUtils.sendUsage(this, channel);
        }
    }

    @Override
    public String getCommand() {
        return "pin";
    }

    @Override
    public String getDescription() {
        return "Pin a message";
    }

    @Override
    public String getUsage() {
        return "`{%}pin <messageID|message>` - Pins a message either by ID or by typing a message";
    }

    @Override
    public CommandType getType() {
        return CommandType.MODERATION;
    }

    @Override
    public boolean isDefaultPermission() {
        return false;
    }
}

@@ -633,17 +633,16 @@
  && 
-!
 args%5B0%5D.
 repl
@@ -641,110 +641,34 @@
 %5B0%5D.
-replaceAll
+matches
 (%22%5B
-%5E
 0-9%5D
-%22, %22%22).isEmpty()) %7B%0A            String messageId = args%5B0%5D.replaceAll(%22%5B%5E0-9%5D%22, %22%22);
+%7B18,22%7D%22)) %7B
 %0A   
@@ -717,17 +717,22 @@
 yId(
-messageId
+args%5B0%5D.trim()
 ).co
@@ -902,74 +902,8 @@
 0)%7B%0A
-            String pinMessage = MessageUtils.getMessage(args, 0);%0A
     
@@ -1081,19 +1081,62 @@
 ion(
-pinMessage)
+MessageUtils.getMessage(args, 0))%0A                    
 .bui

Make ammendments