Exemplo n.º 1
0
        public static async Task Maindo(SocketMessage arg)
        {
            try
            {
                string ToBuy = arg.Content.ToLower().Contains(' ') ? arg.Content.ToLower().Split(' ')[1] : null;
                long   Count = 1;

                if (arg.Content.ToLower().Split(' ').Length >= 3)
                {
                    if (!long.TryParse(arg.Content.ToLower().Split(' ')[2], out Count))
                    {
                        Count = 1;
                    }
                }

                if (ToBuy != null)
                {
                    if (Enum.TryParse(ToBuy, out Product ProductBuying))
                    {
                        Receipt Buy = Economy.Buy(ProductBuying, Count, arg.Author.Id);
                        if (Buy.Success)
                        {
                            await arg.Channel.SendMessageAsync($"Successfully bought `{ProductBuying}` (x{Buy.Amount}) for `${Buy.Cost}`.");
                        }
                        else
                        {
                            await arg.Channel.SendMessageAsync($"Not enough money! You have `${ShopClass.ReadCurrency(arg.Author.Id)}` and need `${Buy.Cost}`");
                        }
                    }
                    else
                    {
                        await arg.Channel.SendMessageAsync($@"The item ""`{ToBuy}`"" doesn't exist. :pensive");
                    }
                }
                else
                {
                    await arg.Channel.SendMessageAsync($"Please specify what you'd like to buy!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }