I have been working on my discord bot recently and I want to create a command which sends a random photo from given array. At present I have this code:
[Command("sendpic"), Summary("")]
public async Task SendPic()
{
string[] RandomPic = { "https://images.unsplash.com/photo-1536746803623-cef87080bfc8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80",
"https://s3.amazonaws.com/artallnight/static/files/2018/08/14154730/back-1024x532.jpg",
"https://www.abc.net.au/news/image/9776766-3x2-700x467.jpg",
"https://static1.squarespace.com/static/58d2d1d003596ef5151dd694/t/5911277b893fc011d4e8543d/1494296445782/stars2.jpg?format=1500w"
};
Random random = new Random();
int randomNumber = random.Next(0, 3);
EmbedBuilder d = new EmbedBuilder();
d.WithColor(120, 40, 23);
if (randomNumber == 1)
{
await Context.Channel.SendMessageAsync(RandomPic[1]);
} else if (randomNumber == 2) {
await Context.Channel.SendMessageAsync(RandomPic[2]);
} else if (randomNumber == 3){
await Context.Channel.SendMessageAsync(RandomPic[3]);
} else {
await Context.Channel.SendMessageAsync(RandomPic[0]);
}
}
but it seems to be not working since it only sends 1 picture whenever I call the "sendpic" command. How do I make it to send given pics from array(each one at every call?)