lundi 6 février 2017

random.Next(0,7) ArgumentOutOfRangeException C#

I'm trying to add a dice command to my discord bot It works perfectly if I do not specify the range -> rand.Next() However, when I add a range (1,7), it keeps showing "Exception: ArgumentOutOfRangeException"

      commands.CreateCommand("dice")
           .Do(async (e) =>
            {
                Random rand = new Random();
                int num = rand.Next(1,7); 
                string s = Convert.ToString(num);
                await e.Channel.SendMessage(s);
            });

!http://ift.tt/2klvguK

edit: (1,7) instead of (0,7)




Aucun commentaire:

Enregistrer un commentaire