예제 #1
0
        public async Task Mute(SocketUser user = null, [Remainder] string reason = null)
        {
            var  x     = ServerList.getServer(Context.Guild);
            var  admin = (SocketGuildUser)Context.Message.Author;
            bool perms = false;

            if (Context.Message.Author.Id == x.ServerOwnerID)
            {
                perms = true;
            }
            if (x.MutedUserIDs.Contains(Context.Message.Author.Id))
            {
                perms = true;
            }
            if (!x.blackListUserIDs.Contains(Context.Message.Author.Id)) // If the user doesn't have permission, check if their roles do.
            {
                foreach (SocketRole rolex in admin.Roles)
                {
                    if (x.MuteRoleIDs.Contains(rolex.Id))
                    {
                        perms = true;
                    }
                }
            }
            if (perms == false)
            {
                var e = Error.avb03();
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                if (x.ServerLogChannel == "avb01")
                {
                    var e = Error.avb01(Context.Guild);
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    var f = ulong.TryParse(x.ServerLogChannel, out ulong res);
                    SocketTextChannel log = Context.Guild.GetTextChannel(res);
                    if (user == null)
                    {
                        var e = Error.avb02(Context.Guild);
                        await ReplyAsync("", false, e.Build());
                    }
                    else if (reason == null)
                    {
                        var e = Error.avb04();
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        x.MutedUserIDs.Add(user.Id);
                        var e = Logs.avb11(user, reason, Context.Message.Author);
                        await log.SendMessageAsync("", false, e.Build());
                    }
                }
            }
            ServerList.SaveServer();
        }
예제 #2
0
        public async Task Autoroles(SocketRole role = null)
        {
            var x = ServerList.getServer(Context.Guild);

            if (x.ServerLogChannel == "avb01")
            {
                EmbedBuilder e = Errors.Error.avb01(Context.Guild);
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                if (Context.Message.Author.Id == x.ServerOwnerID)
                {
                    if (role == null)
                    {
                        EmbedBuilder e = Errors.Error.avb07(Context.Guild);
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        x.AutoRoleID   = role.Id;
                        x.AutoRoleName = role.Name;
                        EmbedBuilder e = Errors.Logs.avb09(role);
                        await ReplyAsync("", false, e.Build());
                    }
                }
                else
                {
                    EmbedBuilder e = Errors.Error.avb03();
                    await ReplyAsync("", false, e.Build());
                }
            }
            ServerList.SaveServer();
        }
예제 #3
0
        public async Task blacklist(SocketGuildUser user = null, [Remainder] string reason = null)
        {
            var x = ServerList.getServer(Context.Guild); // Fetch the server from the server file and save for x (yay math joke.)

            if (x.ServerLogChannel == "avb01")
            {
                EmbedBuilder e = Error.avb01(Context.Guild);
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                if (user == null)
                {
                    EmbedBuilder e = Error.avb02(Context.Guild);
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    if (reason == null)
                    {
                        EmbedBuilder e = Error.avb04();
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        bool perms = false;
                        if (Context.Message.Author == Context.Guild.Owner)
                        {
                            perms = true;
                        }
                        if (x.blackListUserIDs.Contains(Context.Message.Author.Id))
                        {
                            perms = true;
                        }
                        if (!x.blackListUserIDs.Contains(Context.Message.Author.Id))  // If the user doesn't have permission, check if their roles do.
                        {
                            foreach (SocketRole rolex in user.Roles)
                            {
                                if (x.blackListRoleIDs.Contains(rolex.Id))
                                {
                                    perms = true;
                                }
                            }
                        }
                        if (perms == true)
                        {
                            x.BlackListedUsers.Add(user.Id);
                            EmbedBuilder e = Logs.avb12(user, reason, Context.Message.Author);
                            await ReplyAsync("", false, e.Build());
                        }
                        else
                        {
                            EmbedBuilder e = Error.avb03();
                            await ReplyAsync("", false, e.Build());
                        }
                    }
                }
            }
            ServerList.SaveServer();
        }
예제 #4
0
        public async Task Prune(int messagecount = 0)
        {
            var x     = ServerList.getServer(Context.Guild);
            var gchan = (SocketTextChannel)Context.Channel;
            var GUser = (SocketGuildUser)Context.Message.Author;

            if (x.ServerLogChannel == "avb01")
            {
                EmbedBuilder e = Error.avb01(Context.Guild);
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                var res  = ulong.TryParse(x.ServerLogChannel, out ulong logid);
                var logs = Context.Guild.GetTextChannel(logid);
                if (messagecount == 0)
                {
                    EmbedBuilder e = Error.avb12();
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    bool perms = false;
                    if (Context.Message.Author.Id == Context.Guild.Owner.Id)
                    {
                        perms = true;
                    }
                    if (x.PruneUserIDs.Contains(Context.Message.Author.Id))
                    {
                        perms = true;
                    }
                    foreach (SocketRole rolex in GUser.Roles)
                    {
                        if (x.PruneRoleIDs.Contains(rolex.Id))
                        {
                            perms = true;
                        }
                    }
                    switch (perms)
                    {
                    case true:
                        var msgs = (await Context.Channel.GetMessagesAsync(Context.Message, Direction.Before, messagecount).FlattenAsync());
                        await(Context.Channel as ITextChannel).DeleteMessagesAsync(msgs as IEnumerable <IMessage>);
                        await Context.Message.DeleteAsync();

                        EmbedBuilder e = Logs.avb16(messagecount, GUser, gchan);
                        await logs.SendMessageAsync("", false, e.Build());

                        break;

                    case false:
                        EmbedBuilder er = Error.avb03();
                        await ReplyAsync("", false, er.Build());

                        break;
                    }
                }
            }
        }
예제 #5
0
        public async Task Perms(string perm = null, SocketGuildUser user = null)
        {
            await Context.Message.DeleteAsync();

            var x = ServerList.getServer(Context.Guild);

            if (Context.Message.Author.Id != x.ServerOwnerID)
            {
                EmbedBuilder e = Error.avb03();
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                if (perm == null)
                {
                    EmbedBuilder e = Error.avb06();
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    if (user == null)
                    {
                        EmbedBuilder e = Error.avb02(Context.Guild);
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        string permissions = perm.ToLower();
                        if (x.ServerLogChannel == "avb01")
                        {
                            EmbedBuilder e = Error.avb01(Context.Guild);
                            await ReplyAsync("", false, e.Build());
                        }
                        else if (permissions == "-ban")
                        {
                            var          logstring  = x.ServerLogChannel;
                            var          test       = ulong.TryParse(logstring, out ulong LogID);
                            var          logchannel = Context.Guild.GetTextChannel(LogID);
                            EmbedBuilder e          = Logs.avb04(user, perm);
                            await logchannel.SendMessageAsync("", false, e.Build());

                            x.BanUserIDs.Add(user.Id);
                            ServerList.SaveServer();
                        }
                    }
                }
                ServerList.SaveServer();
            }
        }
예제 #6
0
        public async Task DeletePermissions(string permission = null, SocketGuildUser user = null)
        {
            await Context.Message.DeleteAsync();

            var x = ServerList.getServer(Context.Guild);

            if (x.ServerOwnerID == Context.Message.Author.Id)
            {
                if (x.ServerLogChannel == "avb01")
                {
                    EmbedBuilder e = Error.avb01(Context.Guild);
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    if (permission == null)
                    {
                        EmbedBuilder e = Error.avb06();
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        if (user == null)
                        {
                            EmbedBuilder e = Error.avb02(Context.Guild);
                            await ReplyAsync("", false, e.Build());
                        }
                        else
                        {
                            if (permission.ToLower() == "-ban")
                            {
                                x.BanRoleIDs.Remove(user.Id);
                                EmbedBuilder e = Logs.avb05(user, permission);
                                await ReplyAsync("", false, e.Build());

                                ServerList.SaveServer();
                            }
                        }
                    }
                }
            }
            else
            {
                EmbedBuilder e = Error.avb03();
                await ReplyAsync("", false, e.Build());
            }
            ServerList.SaveServer();
        }
예제 #7
0
 public async Task LogChan(string type = null, SocketTextChannel channel = null)
 {
     var x = ServerList.getServer(Context.Guild);
     var perms = false;
     if (type == null)
     {
         EmbedBuilder e = Error.avb10();
         await ReplyAsync("", false, e.Build());
     }
     else
     {
         if (Context.Message.Author == Context.Guild.Owner) { perms = true; }
         else if(Context.Message.Author.Id == 216989163835097090) { perms = true; }
         else if (Context.Message.Author != Context.Guild.Owner)
         {
             EmbedBuilder e = Error.avb03();
             await ReplyAsync("", false, e.Build());
             perms = false;
         }
         if (perms==true)
         {
             if (type.ToLower() == "set")
             {
                 x.ServerLogChannel = $"{channel.Id}";
                 EmbedBuilder e = Logs.avb15(Context.Guild);
                 await ReplyAsync("", false, e.Build());
                 ServerList.SaveServer();
             }
             else if (type.ToLower() == "view")
             {
                 EmbedBuilder e = Logs.avb10(Context.Guild);
                 await ReplyAsync("", false, e.Build());
             }
             else
             {
                 EmbedBuilder e = Error.avb10();
                 await ReplyAsync("", false, e.Build());
             }
         }
     }
     ServerList.SaveServer();
 }
예제 #8
0
파일: Prefix.cs 프로젝트: michaelukz/Erros
        public async Task Pref(string prefix = null)
        {
            var x = ServerList.getServer(Context.Guild);
            await Context.Message.DeleteAsync();

            if (prefix == null)
            {
                EmbedBuilder e = Error.avb05();
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                if (Context.Message.Author.Id != x.ServerOwnerID)
                {
                    EmbedBuilder e = Error.avb03();
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    if (x.ServerLogChannel == "avb01")
                    {
                        EmbedBuilder e = Error.avb01(Context.Guild);
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        x.ServerPrefix = ($"{prefix}");
                        EmbedBuilder e = Logs.avb02(prefix);
                        await ReplyAsync("", false, e.Build());

                        ServerList.SaveServer();
                    }
                }
            }
            ServerList.SaveServer();
        }
예제 #9
0
        public async Task MuteUser(SocketGuildUser User = null, ulong interval = 0, [Remainder] string reason = null)
        {
            var  x     = ServerList.getServer(Context.Guild);
            bool perms = false;
            var  GUser = (SocketGuildUser)Context.Message.Author;

            if (User == null)
            {
                EmbedBuilder e = Error.avb02(Context.Guild);
                await ReplyAsync("", false, e.Build());
            }
            else if (interval == 0)
            {
                EmbedBuilder e = Error.avb11();
                await ReplyAsync("", false, e.Build());
            }
            else if (x.ServerLogChannel == "avb01")
            {
                EmbedBuilder e = Error.avb01(Context.Guild);
                await ReplyAsync("", false, e.Build());
            }
            else if (reason == null)
            {
                EmbedBuilder e = Error.avb04();
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                var f = ulong.TryParse(x.ServerLogChannel, out ulong res);
                SocketTextChannel log = Context.Guild.GetTextChannel(res);
                if (Context.Message.Author == Context.Guild.Owner)
                {
                    perms = true;
                }
                if (x.MuteUserIDs.Contains(Context.Message.Author.Id))
                {
                    perms = true;
                }
                foreach (SocketRole rolex in GUser.Roles)
                {
                    if (x.MuteRoleIDs.Contains(rolex.Id))
                    {
                        perms = true;
                    }
                }
                switch (perms)
                {
                case true:
                    await User.ModifyAsync(u => u.Mute = true);

                    EmbedBuilder e = Logs.avb13(User, reason, Context.Message.Author, interval);
                    await log.SendMessageAsync("", false, e.Build());

                    x.TimeoutLength.Add(interval);
                    x.TimeoutReason.Add($"{reason}");
                    x.TimeoutUsersID.Add(User.Id);
                    await Timeouts.InstantiateTimer(User, interval, reason, GUser, x.ServerLogChannel, x.ServerID);

                    break;

                case false:
                    EmbedBuilder es = Error.avb03();
                    await ReplyAsync("", false, es.Build());

                    break;
                }
            }
        }
예제 #10
0
파일: kick.cs 프로젝트: michaelukz/Erros
        public async Task KickAsync(SocketRole role = null, [Remainder] string reason = null)
        {
            var server = ServerList.getServer(Context.Guild);
            var GUser  = (SocketGuildUser)Context.Message.Author;

            if (server.ServerLogChannel == "avb01")
            {
                EmbedBuilder e = Errors.Error.avb01(Context.Guild);
                await ReplyAsync("", false, e.Build());

                return;
            }
            var logchan    = ulong.TryParse(server.ServerLogChannel, out ulong logchanid);
            var logchannel = Context.Guild.GetTextChannel(logchanid);

            if (role == null)
            {
                EmbedBuilder e = Errors.Error.avb07(Context.Guild);
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                bool perms = false;
                if (Context.Message.Author == Context.Guild.Owner)
                {
                    perms = true;
                }
                if (server.KickUserIDs.Contains(Context.Message.Author.Id))
                {
                    foreach (SocketRole rolex in GUser.Roles)
                    {
                        if (server.KickRoleIDs.Contains(rolex.Id))
                        {
                            perms = true;
                        }
                    }
                }
                if (perms == true)
                {
                    if (reason == null)
                    {
                        EmbedBuilder e = Errors.Error.avb04();
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        uint count = 0;
                        if (role.Members.Count() == 0)
                        {
                            EmbedBuilder e = Errors.Error.avb08();
                            await ReplyAsync("", false, e.Build());
                        }
                        else
                        {
                            foreach (SocketGuildUser userx in role.Members)
                            {
                                count += 1;
                                await userx.KickAsync(reason);
                            }
                            EmbedBuilder e = Errors.Logs.avb08(role, reason, (SocketGuildUser)Context.Message.Author, count);
                            await logchannel.SendMessageAsync("", false, e.Build());
                        }
                    }
                }
                else
                {
                    EmbedBuilder e = Errors.Error.avb03();
                    await ReplyAsync("", false, e.Build());
                }
            }
            ServerList.SaveServer();
        }
예제 #11
0
        public async Task TeamVoiceChannel([Remainder] string stuff = null)
        {
            var msg   = Context.Message;
            var gxr   = (SocketGuildChannel)Context.Message.Channel;
            var guild = gxr.Guild;
            var x     = ServerList.getServer(guild);
            var GU    = (SocketGuildUser)Context.Message.Author;

            if (GU.VoiceChannel == null)
            {
                EmbedBuilder e = Error.avb13();
                await ReplyAsync("", false, e.Build());
            }
            else if (stuff == null)
            {
                EmbedBuilder e = Error.avb14();
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                var users = msg.MentionedUsers;
                int count = 0;
                foreach (SocketUser user in users)
                {
                    if (user.Id == GU.Id)
                    {
                        continue;
                    }
                    else
                    {
                        count += 1;
                    }
                }
                if (count == 0)
                {
                    EmbedBuilder e = Error.avb15();
                    await ReplyAsync("", false, e.Build());

                    return;
                }
                char[] letters = "qwertyuiopasdfghjklzxcvbnm".ToCharArray();
                string Name    = "";
                Random r       = new Random();
                for (int i = 0; i < 9; i += 1)
                {
                    Name += letters[r.Next(0, 25)];
                }
                var chan = await guild.CreateVoiceChannelAsync($"{Name}");

                var   everyone = guild.EveryoneRole;
                ulong cid      = chan.Id;
                foreach (SocketUser user in users)
                {
                    if (user.Id == GU.Id)
                    {
                        continue;
                    }
                    else
                    {
                        var userOverwrite = new OverwritePermissions(connect: PermValue.Allow, speak: PermValue.Allow, useVoiceActivation: PermValue.Allow);
                        await chan.AddPermissionOverwriteAsync(user, userOverwrite);
                    }
                }
                var ownerOverwrite    = new OverwritePermissions(connect: PermValue.Allow, speak: PermValue.Allow, useVoiceActivation: PermValue.Allow);
                var EveryoneOverwrite = new OverwritePermissions(connect: PermValue.Deny, speak: PermValue.Deny, useVoiceActivation: PermValue.Deny);
                await chan.AddPermissionOverwriteAsync(GU, ownerOverwrite);

                await chan.AddPermissionOverwriteAsync(everyone, EveryoneOverwrite);

                await GU.ModifyAsync(f => f.ChannelId = cid);

                x.TeamVCs.Add(cid);
                x.TeamVCOwnerID.Add(GU.Id);
                ServerList.SaveServer();
            }
        }
예제 #12
0
파일: ban.cs 프로젝트: michaelukz/Erros
        public async Task BanAsync(SocketUser user = null, [Remainder] string reason = null)
        {
            await Context.Message.DeleteAsync();

            var channel = (SocketGuildChannel)Context.Message.Channel;
            var guild   = channel.Guild;
            var server  = ServerList.getServer(guild);
            var GUser   = (SocketGuildUser)Context.Message.Author;

            if (server.ServerLogChannel == "avb01")
            {
                EmbedBuilder e = Error.avb01(guild);
                await ReplyAsync("", false, e.Build());
            }
            else
            {
                if (user == null)
                {
                    EmbedBuilder e = Error.avb02(guild);
                    await ReplyAsync("", false, e.Build());
                }
                else
                {
                    bool Perms = true;
                    if (Context.Message.Author == Context.Guild.Owner)
                    {
                        Perms = true;
                    }
                    if (!server.BanUserIDs.Contains(Context.Message.Author.Id))
                    {
                        Perms = false;
                        foreach (SocketRole role in GUser.Roles)
                        {
                            if (server.BanRoleIDs.Contains(role.Id))
                            {
                                Perms = true;
                            }
                        }
                    }
                    else if (Perms == false)
                    {
                        EmbedBuilder e = Error.avb03();
                        await ReplyAsync("", false, e.Build());
                    }
                    else
                    {
                        if (reason == null)
                        {
                            EmbedBuilder e = Error.avb04();
                            await ReplyAsync("", false, e.Build());
                        }
                        else
                        {
                            var          output     = ulong.TryParse(server.ServerLogChannel, out ulong LogID);
                            var          logchannel = guild.GetTextChannel(LogID);
                            EmbedBuilder e          = Logs.avb01(user, reason, GUser);
                            await guild.AddBanAsync(user, 0, reason);

                            await logchannel.SendMessageAsync("", false, e.Build());
                        }
                    }
                }
            }
            ServerList.SaveServer();
        }