C# Looking to make a Discord bot say a line of randomized text before posting an image from a string

803 views Asked by At

There are some bots out there that are able to say a line from a predetermined string of lines they have, then post an image from a string, I was wondering how I would go about doing this? Basically what i want to happen is for the bot to pull a line from one string, then underneath that line, post an image from another string. Both of those strings would be randomized, so the bot can pull a variety of lines and a variety of pictures at the same time

1

There are 1 answers

0
TooBoredToWriteAName On

I assume what you are trying to do is post a random text. First, you must create and define a string array then create the following private function.

private void RegisterStringCommand()
        {
            commands.CreateCommand("text")
                .Description("Posts a random string")
                .Do(async (e) =>
                {
                        int randomArrayIndex = rand.Next(yourarray.Length);
                        string stringToPost = yourarray[randomArrayIndex];
                        await e.Channel.SendMessage(stringToPost);
                });
        }

Call this in the constructer for your bot class.