Exemplo n.º 1
0
 async Task Responce_Unexile(string Msg, MessageEventArgs e)
 {
     if (Exiles.Any(x => x.User == e.User))
     {
         Exiles.Where(w => w.User == e.User).FirstOrDefault().ReduceTime(); WriteLine("Command: Reduced " + e.User.Name + "'s exile time");
     }
     else
     {
         (await e.Channel.SendMessage(e.User.Mention + ", you aren't **Exiled** at the moment.")).Timed(30);
     }
 }
Exemplo n.º 2
0
            async Task Responce_Exile(string Msg, MessageEventArgs e)
            {
                User Target = e.Message.MentionedUsers.FirstOrDefault();
                var  Time   = 0;              // in Seconds.

                if (Target == null)
                {
                    (await e.Channel.SendMessage(":anger: Missing target user for exile\n`Syntax Error`")).Timed(30);
                    WriteLine("Command Error: Could not find target user");
                    return;
                }
                if (Target.Id == Dictionaries.Bot_ID)
                {
                    (await e.Channel.SendMessage("I can't exile myself :grey_exclamation:")).Timed(30);
                    WriteLine("Command Error: Target can not be the Bot");
                    return;
                }
                if (Target.Roles.Any(x => x.Id == Dictionaries.Role_ServerBot || x.Id == Dictionaries.Role_ServerOwner))
                {
                    (await e.Channel.SendMessage("**" + Target.Name + "** is beyond my reach :cry: ")).Timed(30);
                    WriteLine("Command Error: Target is beyond the Bot's reach");
                    return;
                }
                try
                {
                    Msg = Msg.RemoveMentions().RemoveSpaces();
                    if (!Msg.Contains('#'))
                    {
                        Time = 300;
                    }
                    else
                    {
                        if (Msg.Contains(':'))
                        {
                            Time += int.Parse(Msg.Substring(Msg.IndexOf(':') + 1));
                            if (Msg.Between('#', ':') != "")
                            {
                                Time += 60 * int.Parse(Msg.Between('#', ':'));
                            }
                        }
                        else
                        {
                            Time += 60 * int.Parse(Msg.Substring(Msg.IndexOf('#') + 1));
                        }
                    }
                }
                catch (Exception) { (await e.Channel.SendMessage(":anger: could not determine Exile time\n`Syntax Error`")).Timed(30); WriteLine("Command Error: Could not determine exile time"); return; }

                UserDatas.GetByUser(Target).ExileTime += Time;
                if (Exiles.Any(x => x.User == Target))
                {
                    Exiles.Where(w => w.User == Target).FirstOrDefault().AddTime(Time);
                    WriteLine("Command: Added " + Time + " seconds to " + Target.Name + "'s exile");
                }
                else
                {
                    Exiles.Add(new Exile()
                    {
                        User = Target, ExpireTime = DateTime.Now.AddSeconds(Time), e = e, Timeleft = Time
                    });
                    var ExileTarget = Exiles.Last();
                    ExileTarget.ExileUser();
                    ExileTarget.Timer.Start();
                    ExileTarget.Timer.Disposed += (S, E) =>
                    {
                        while (ConnectionState != "Connected")
                        {
                            System.Threading.Thread.Sleep(500);
                        }
                        ExileTarget.UnexileUser();
                        Exiles.Remove(ExileTarget);
                    };
                    WriteLine("Command: Exiled " + Target.Name + " for " + Time + " seconds");
                }
            }