#Help with JDA bot creation.

3 messages · Page 1 of 1 (latest)

heavy ice
#

Hello, I have been trying to figure out how to make it so that if my method called test is given a parameter that equals bold, it will take the reply string and concatenate two asterisks on both sides of the string and return it. I have manually done this but when it comes down to having three parameters such as 3 modifiers, you have yourself 64 combinations and I'd like to be able to do 4 and not have to write 256 lines of code. this is my code so far, the first block is the test method that I can't even figure out where to start, and the second one,(which will not run since it requires multiple other files), is the manual version that I am trying to automate.

public class main {
    public static void main(String[] args) {

    }
    public static void test(String test){
        String reply = "";
        switch(test){
            case "bold" ->{
                reply = "**"+"dwdaw"+"**"
            }
        }
    }
}
public static String mod(String mod,String textOption){
        String reply = "";
        switch(mod.toLowerCase()){
            case "bold" ->{reply = "**" + textOption + "**";}
            case "italic" ->{reply = "*" + textOption + "*";}
            case "strike" ->{reply = "~~" + textOption + "~~";}
            case "under" ->{reply = "__" + textOption + "__";}
            default ->{reply = "invalid modifier";}
        }
        return reply;
    }
serene sapphireBOT
#

This post has been reserved for your question.

Hey @heavy ice! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.