Ejemplo n.º 1
0
 public async Task <BotGearPreBannedUser> GetPreBannedUserbyIdAndServerId(string id, string serverid)
 {
     try
     {
         BotGearPreBannedUser user = null;
         if (id != null && serverid != null)
         {
             user = db.PreBannedUsers.FirstOrDefault(x => x.UserId == id && x.ServerId == serverid);
         }
         return(user);
     }
     catch (Exception ex)
     {
         CommonTools.ErrorReporting(ex);
         return(null);
     }
 }
Ejemplo n.º 2
0
        public async Task UnBanUser(string iuser, IGuild iguild)
        {
            try
            {
                if (iuser != null)
                {
                    BotGearPreBannedUser user = await this.GetPreBannedUserbyIdAndServerId(iuser, Convert.ToString(iguild.Id));

                    var srvid = Convert.ToString(iguild.Id);



                    db.PreBannedUsers.Remove(user);

                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);
            }
        }
Ejemplo n.º 3
0
        public async Task banUser(string iuser, string reason, IGuild iguild)
        {
            try
            {
                if (iuser != null && reason != null && iguild != null)
                {
                    BotGearPreBannedUser exuser = await this.GetPreBannedUserbyIdAndServerId(iuser, Convert.ToString(iguild.Id));

                    BotGearServer srv = this.conv.IGuildToBotGearServer(iguild);

                    if (exuser == null && srv != null)
                    {
                        if (await srvMngr.ServerExists(srv.Id) != true)
                        {
                            await this.srvMngr.addServer(iguild);
                        }
                        else
                        {
                            string id = srv.Id;
                            srv = await srvMngr.getServerbyId(id);
                        }
                        exuser          = new BotGearPreBannedUser();
                        exuser.ServerId = srv.Id;
                        exuser.UserId   = iuser;
                        exuser.Date     = DateTime.Now;
                        exuser.Reason   = reason;
                        db.PreBannedUsers.Add(exuser);

                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);
            }
        }