Пример #1
0
        public Task TestOverwritePermissionModifyNoParam()
        {
            // test for all Text allowed, none denied
            var original = new OverwritePermissions(ChannelPermissions.Text.RawValue, ChannelPermissions.None.RawValue);

            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // none allowed, text denied
            original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Text.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // category allowed, none denied
            original = new OverwritePermissions(ChannelPermissions.Category.RawValue, ChannelPermissions.None.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // none allowed, category denied
            original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Category.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // DM allowed, none denied
            original = new OverwritePermissions(ChannelPermissions.DM.RawValue, ChannelPermissions.None.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // none allowed, DM denied
            original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.DM.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // voice allowed, none denied
            original = new OverwritePermissions(ChannelPermissions.Voice.RawValue, ChannelPermissions.None.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // none allowed, voice denied
            original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Voice.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // group allowed, none denied
            original = new OverwritePermissions(ChannelPermissions.Group.RawValue, ChannelPermissions.None.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // none allowed, group denied
            original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Group.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            // none allowed, none denied
            original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.None.RawValue);
            Assert.Equal(original.AllowValue, original.Modify().AllowValue);
            Assert.Equal(original.DenyValue, original.Modify().DenyValue);

            return(Task.CompletedTask);
        }
Пример #2
0
        private async Task Invite([Remainder] string RemainingText)
        {
            var acm = discordSettings.AutoChannelManage;

            if (CheckIfInACM(acm, user))
            {
                if (Context.Message.MentionedUsers.Count > 5)
                {
                    addtext(Context.Guild, Context.Message.Channel as SocketTextChannel, user, "Only five users at a time", messageHandler);
                }
                else if (Context.Message.MentionedUsers.Count == 0)
                {
                    addtext(Context.Guild, Context.Message.Channel as SocketTextChannel, user, "You didnt mention anyone", messageHandler);
                }
                else
                {
                    var perms = new Discord.OverwritePermissions();

                    perms = perms.Modify(Discord.PermValue.Inherit, Discord.PermValue.Inherit, Discord.PermValue.Inherit, Discord.PermValue.Allow, Discord.PermValue.Allow,
                                         Discord.PermValue.Inherit, Discord.PermValue.Inherit, Discord.PermValue.Inherit, Discord.PermValue.Inherit, Discord.PermValue.Allow,
                                         Discord.PermValue.Inherit, Discord.PermValue.Inherit, Discord.PermValue.Allow, Discord.PermValue.Allow, Discord.PermValue.Inherit,
                                         Discord.PermValue.Inherit, Discord.PermValue.Allow, Discord.PermValue.Allow, Discord.PermValue.Inherit, Discord.PermValue.Inherit);


                    foreach (var a in Context.Message.MentionedUsers)
                    {
                        await user.VoiceChannel.AddPermissionOverwriteAsync(a, perms);
                    }

                    addtext(Context.Guild, Context.Message.Channel as SocketTextChannel, user, "The users can now join your channel", messageHandler);
                }
            }
        }