Exemplo n.º 1
0
        private static void Client_OnMessageReceived(DiscordSocketClient client, MessageEventArgs msg)
        {
            var message = msg.Message.Content;

            if (!message.Contains("gift/"))
            {
                return;
            }
            var gift      = Removebefore(message);
            var finalgift = gift.Split()[0];

            finalgift = finalgift.Replace("gift/", "");

            try
            {
                var sw = new Stopwatch();
                sw.Start();
                client.RedeemGift(finalgift);
                sw.Stop();
                Console.Write("    [", Color.Purple);
                Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second,
                              Color.White);
                Console.Write("] ", Color.Purple);
                Console.Write("Successfully redeemed gift  - discord.gift/" + finalgift + " (" +
                              sw.ElapsedMilliseconds + " ms)", Color.White);
            }
            catch (Exception)
            {
                try
                {
                    if (client.GetGift(finalgift).Consumed)
                    {
                        Console.Write("    [", Color.Purple);
                        Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second,
                                      Color.White);
                        Console.Write("] ", Color.Purple);
                        Console.Write("Gift already claimed from - discord.gift/" + finalgift +
                                      Environment.NewLine, Color.White);
                    }
                    else
                    {
                        Console.Write("    [", Color.Purple);
                        Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second,
                                      Color.White);
                        Console.Write("] ", Color.Purple);
                        Console.Write("Error redeeming gift - discord.gift/" + finalgift + Environment.NewLine,
                                      Color.White);
                    }
                }
                catch (Exception)
                {
                    Console.Write("    [", Color.Purple);
                    Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second,
                                  Color.White);
                    Console.Write("] ", Color.Purple);
                    Console.Write("Unknown Gift - discord.gift/" + finalgift + Environment.NewLine,
                                  Color.White);
                }
            }
        }
Exemplo n.º 2
0
        private static void Client_OnMessageReceived(DiscordSocketClient client, MessageEventArgs msg)
        {
            var message = msg.Message.Content.ToString();

            if (message.Contains("gift/"))
            {
                string gift      = removebefore(message);
                string finalgift = gift = gift.Split()[0];
                finalgift = finalgift.Replace("gift/", "");

                try
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    client.RedeemGift(finalgift);
                    sw.Stop();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("[");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("] ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("Succesfully redeemed gift  - discord.gift/" + finalgift + " (" + sw.ElapsedMilliseconds + " ms)");
                }
                catch (Exception ex)
                {
                    try
                    {
                        if (client.GetGift(finalgift).Consumed == true)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("[");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("] ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write("Gift already claimed from - discord.gift/" + finalgift + Environment.NewLine);
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("[");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("] ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write("Error redeeming gift - discord.gift/" + finalgift + Environment.NewLine);
                        }
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("[");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("] ");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("Unknow Gift - discord.gift/" + finalgift + Environment.NewLine);
                    }
                }
            }
        }