private async Task AllowOnlyRoles(IGuild guild, IVoiceChannel voiceChannel,
                                      GuildGroupsContext guildGroupsContext)
    {
        var rolePermissions = new OverwritePermissions().Modify(viewChannel: PermValue.Allow,
                                                                connect: PermValue.Allow,
                                                                speak: PermValue.Allow);

        var denyPermissions = new OverwritePermissions().Modify(viewChannel: PermValue.Deny,
                                                                connect: PermValue.Deny,
                                                                speak: PermValue.Deny);

        await voiceChannel.AddPermissionOverwriteAsync(guild.EveryoneRole, denyPermissions);

        await voiceChannel.AddPermissionOverwriteAsync(guildGroupsContext.CurrentUser, rolePermissions);

        if (guildGroupsContext.Roles != null)
        {
            foreach (var role in guildGroupsContext.Roles)
            {
                await voiceChannel.AddPermissionOverwriteAsync(role, rolePermissions);
            }
        }

        if (guildGroupsContext.Users != null)
        {
            foreach (var user in guildGroupsContext.Users)
            {
                await voiceChannel.AddPermissionOverwriteAsync(user, rolePermissions);
            }
        }
    }
    public async Task CreateVoiceChannelAsync(IGuild guild, string name, GuildGroupsContext guildGroupsContext)
    {
        var guildConfiguration = await _discordBotConfigurationService.GetGuildConfigurationAsync(guild.Id);

        if (guildConfiguration == null)
        {
            throw new ArgumentException("Не указана категория для создания голосовых каналов!");
        }

        var categoryChannel =
            await DiscordBotUtils.GetCategoryAsync(guild, guildConfiguration.VoiceChannelCreationCategory);

        Action <VoiceChannelProperties> voiceChannelProperties = channel => { };

        if (categoryChannel != null)
        {
            voiceChannelProperties += channel => channel.CategoryId = categoryChannel.Id;
        }

        var voiceChannel = await guild.CreateVoiceChannelAsync(name, voiceChannelProperties);

        if (guildGroupsContext != null)
        {
            if (guildGroupsContext.Roles != null && guildGroupsContext.Roles.Any() ||
                guildGroupsContext.Users != null && guildGroupsContext.Users.Any())
            {
                await AllowOnlyRoles(guild, voiceChannel, guildGroupsContext);
            }
        }

        RunDeletionCheck(voiceChannel.Id);
    }
    public GuildGroupsContext GetGuildGroupsContextFromMessage(IGuild guild, IUser user, ref string message)
    {
        var guildGroupsContext = new GuildGroupsContext
        {
            CurrentUser = user,
            Roles       = GetRolesFromMessage(guild, ref message),
            Users       = GetUsersFromMessage(guild, ref message)
        };

        message = message.Trim();
        return(guildGroupsContext);
    }